Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • Aggregate
  • Aggregate_Relationship
  • AssetAdminQuotaExtension
  • AttachedFilesExtension
  • BookingWidget
  • CheckoutPageExchangeExtension
  • ClassInfo
  • ControllerRedirectExtension
  • CSSContentParser
  • DisableJSValidation
  • Extension
  • HtmlEditorQuotaExtension
  • ManifestBuilder
  • MobileExtension
  • Object
  • PaymentMethodAutoHide
  • ProductSearchFormExtension
  • SS_Cache
  • TokenisedRegularExpression
  • ValidationResult
  • YamlFixture

Functions

  • __autoload
  • _t
  • array_fill_keys
  • getClassFile
  • getSysTempDir
  • getTempFolder
  • increase_memory_limit_to
  • increase_time_limit_to
  • project
  • singleton
  • stripslashes_recursively
  • translate_memstring
  1 <?php
  2 
  3 class CheckoutPageExchangeExtension extends Extension {
  4     function extraStatics() {   }
  5     
  6     static $statuses1C = array(
  7         'Unpaid' => 'Новый',
  8         'Query' => 'Ждем оплату',
  9         'Paid' => 'В работе',
 10         'Processing' => 'В работе',
 11         'Sent' => 'На отправке',
 12         'Complete' => 'Завершен',
 13         'AdminCancelled' => 'Отменен',
 14         'MemberCancelled' => 'Отменен',
 15         
 16     );
 17     
 18     
 19     function OnAfterOrder(& $order) {       
 20         $sc = SiteConfig::current_site_config();
 21         $document = array();
 22         $document_counter = 0;
 23         
 24         $date = date('Y-m-d', strtotime($order->Created));
 25         $time = date('H:i:s', strtotime($order->Created));
 26 
 27         $document['Документ' . $document_counter] = array(
 28             'Ид'          => $order->ID,
 29             'Номер'       => $order->ID,
 30             'Дата'        => $date,
 31             'Время'       => $time,
 32             'Валюта'      => $sc->CatalogCurrency,
 33             'Курс'        => 1,
 34             'ХозОперация' => 'Заказ товара',
 35             'Роль'        => 'Продавец',
 36             'Сумма'       => $order->GrandTotal,
 37             'Комментарий' => $order->ClientNotes
 38         );              
 39         $document['Документ' . $document_counter]['Контрагенты']['Контрагент'] = array(
 40              'Ид'                 => $order->MemberID . '#' . $order->Email,
 41             'Наименование'          => trim($order->LastName . ' ' . $order->ClientName . ' ' . $order->SureName),
 42             'Роль'               => 'Покупатель',
 43             'ПолноеНаименование'  => trim($order->LastName . ' ' . $order->ClientName . ' ' . $order->SureName),
 44             'Фамилия'            => $order->LastName,
 45             'Имя'                      => $order->ClientName,
 46             'Адрес' => array(
 47                 'Представление'    => $order->Address.', '.$order->City.', '.$order->PostalCode.', '.$order->Country
 48             ),
 49             'Контакты' => array(
 50                 'Контакт1' => array(
 51                     'Тип' => 'ТелефонРабочий'
 52                     ,'Значение' => $order->Phone
 53                 )
 54                 ,'Контакт2'  => array(
 55                      'Тип' => 'Почта'
 56                     ,'Значение' => $order->Email
 57                 )
 58             )
 59         );
 60         
 61         
 62 
 63         // Товары
 64         $products = $order->Items();
 65 
 66         $product_counter = 0;
 67         foreach ($products as $product) {
 68             $id = $product->LinkedID;
 69             $document['Документ' . $document_counter]['Товары']['Товар' . $product_counter] = array(
 70                  'Ид'             => $id
 71                 ,'Артикул'         => $product->ImportID 
 72                 ,'Наименование'   => $product->Title
 73                 ,'ЦенаЗаЕдиницу'  => $product->Price
 74                 ,'Количество'     => $product->Quantity
 75                 ,'Сумма'          => $product->TotalPrice
 76             );
 77             $product_counter++;
 78         }               
 79         
 80         //Способ доставки
 81         if ($order->hasMethod('ShippingMethod') && ($method = $order->ShippingMethod())) {
 82             $document['Документ' . $document_counter]['ЗначенияРеквизитов']['ЗначениеРеквизита2']= array(                    
 83                 'Наименование' => 'Способ доставки',
 84                 'Значение'=> $method->Name,
 85             );
 86         }
 87         
 88         //Доставка              
 89         if ($order->ShippingTotal) {
 90             $document['Документ' . $document_counter]['Товары']['Товар' . $product_counter] = array(
 91                  'Ид'         => ''
 92                 ,'Наименование' => 'Доставка'
 93                 ,'ЦенаЗаЕдиницу'=> $order->ShippingTotal
 94                 ,'Количество' => 1
 95                 ,'Сумма'       => $order->ShippingTotal
 96             );
 97         }
 98         
 99         //Статус                              
100         $document['Документ' . $document_counter]['ЗначенияРеквизитов']['ЗначениеРеквизита0']= array(                          
101             'Наименование' => 'Статус заказа',
102             'Значение'=> self::$statuses1C[$order->Status],                     
103         );
104                         
105         //Метод оплаты
106         if ($order->hasMethod('PaymentType') && ($method = $order->PaymentType())) {        
107             $document['Документ' . $document_counter]['ЗначенияРеквизитов']['ЗначениеРеквизита1'] = array(                       
108                 'Наименование' => 'Метод оплаты',
109                 'Значение'=> $method->Title,                    
110             );
111         }           
112         
113                 
114         /*
115         $this->model_sale_order->addOrderHistory($orders_data['order_id'], array(
116             'order_status_id' => $params['new_status'],
117             'comment'         => '',
118             'notify'          => $params['notify']
119         ));
120         */
121         
122         
123         $document_counter++;
124         
125         
126         $root = '<?xml version="1.0" encoding="utf-8"?><КоммерческаяИнформация ВерсияСхемы="2.04" ДатаФормирования="' . date('Y-m-d', time()) . '" />';
127         $xml = $this->array_to_xml($document, new SimpleXMLElement($root));
128         
129         file_put_contents(ASSETS_PATH . '/order_'.$order->ID.'.xml', $xml->asXML());
130         
131         
132             
133     }
134     
135     
136     function array_to_xml($data, &$xml) {
137         foreach($data as $key => $value) {
138             if (is_array($value)) {
139                 if (!is_numeric($key)) {
140                     $subnode = $xml->addChild(preg_replace('/\d/', '', $key));
141                     $this->array_to_xml($value, $subnode);
142                 }
143             }
144             else {
145                 $xml->addChild($key, $value);
146             }
147         }
148         return $xml;
149     }
150 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0