system/modules/mp_vima_tickets/assets/ajax.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * Contao Open Source CMS
  4.  *
  5.  * Copyright (c) 2005-2015 Leo Feyer
  6.  *
  7.  * @license LGPL-3.0+
  8.  */
  9. ini_set('display_errors''On');
  10. ini_set('display_startup_errors''On'); 
  11. // Set the script name
  12. define('TL_SCRIPT''system/modules/mp_vima_tickets/assets/ajax.php');
  13. // Initialize the system
  14. define('TL_MODE''BE');
  15. require dirname(__FILE__).'/../../../initialize.php';
  16. use mp\MpVimaTickets;
  17. $cnt 0;
  18. $orders \Isotope\Model\ProductCollection\Order::findBy(['date_paid > 0''mp_vima_synced_at IS NULL'], []);
  19. if($orders) {
  20.     
  21.     foreach($orders as $order) {
  22.         
  23.         $cnt++;
  24.         if($cnt 4) break;
  25.         $addr $order->getRelated('billing_address_id');
  26.         foreach($order->getItems() as $objItem) {
  27.             $product $objItem->getProduct();
  28.             $arr MpVimaTickets::addressToArray($addr);
  29.             $arr['language'] = $order->mp_lang;
  30.             try {
  31.                 $res MpVimaTickets::vimaPost('api/trendfairs/rest/shop/order/' $product->vima_event_id$arr);
  32.                 $order->mp_vima_synced_at time();
  33.             } catch(\Exception $e) {
  34.                 $order->mp_vima_synced_at 10;
  35.             }
  36.             $order->save();
  37.         }
  38.         
  39.     }
  40. }
  41. echo 'done: '.$cnt;