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

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • ForeignKey
  • Hierarchy
  • HTMLText
  • HTMLVarchar
  • ImportLog_Item
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • OrderDataObject
  • OrderHandlersDecorator
  • OrderItemVariationDecorator
  • OrderService
  • OrderServiceOrder
  • OrdersExportDecorator
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
 1 <?php
 2 // Уведомление клиента по емайл (создание заказа и изменение заказа )
 3 class ClientEmailOrderNotification extends OrderHandlersDecorator {
 4         
 5     function OnAfterCreateOrder(& $member) {        
 6         $conf = SiteConfig::current_site_config();      
 7         
 8         $email = $this->getClientEmail();
 9         if ($conf->ClientEmailOrderNotificationActive && $email) {
10             $mail = new Email();
11             $mail->setFrom($conf->CartSenderEmail());
12             $mail->setSubject($this->owner->fill_vars($conf->CartUserNewOrderSubject($this->owner->ID)));
13             $mail->setTo($email);
14             $mail->setTemplate('Order_UserReceiptEmail');
15             $mail->populateTemplate(array(
16                 'PurchaseCompleteMessage' => DataObject::get_one('CheckoutPage')->PurchaseComplete,
17                 'Order' => $this->owner,
18                 'SiteConfig' => $conf,
19             ));
20             $mail->send();
21         }
22     }
23     
24     // после смены стутса
25     function OnAfterChangeStatus($member, $changedStatus, $note) {
26         $conf = SiteConfig::current_site_config();      
27         if (!$conf->ClientEmailOrderNotificationActive) return false;
28             
29         $email = $this->getClientEmail();
30         if (!$email) return false;
31         
32         if (!$note) {
33             $log = DataObject::get_one('Order_StatusLog', "OrderID = {$this->owner->ID}", "Created DESC");
34             $note = $log->Note;
35         }
36         
37         //если отложенная оплата и заказ прошел проверку (статус поменялся с Query на Unpaid), то добавляем в письмо о смене статуса ссылку на оплату
38         $paymentLink = false;
39         if (Order::$use_payments && PaymentSiteConfig::getPaymentAfterConfirm() && $this->owner->isChanged('Status')) {
40             $changes = $this->owner->getChangedFields();
41             $statusData = $changes['Status'];
42             if ($statusData['before'] == 'Unpaid' && $statusData['after'] == 'Query') { //если заказ прошел проверку
43                 $paymentLink = $this->owner->PaymentLink();
44             }
45         }       
46         
47         $mail = new Email();
48         $mail->setFrom($conf->CartSenderEmail());
49         $mail->setTo($email);
50         $mail->setSubject($this->owner->fill_vars($conf->CartUserStatusSubject($this->owner->ID)));
51         $mail->setTemplate('Order_UserStatusEmail');
52                 
53         $mail->populateTemplate(array(
54             'Order' => $this->owner,
55             'Note' => $note,        
56             'Link' => $paymentLink,
57             'SiteConfig' => $conf,
58         ));
59         $mail->send();      
60     }
61     
62     /**
63      * Ищем email клиента
64      * 
65      * @return string
66      */
67     private function getClientEmail() {
68         $email = $this->owner->Email;
69         if (!$email) {
70             if ($member = $this->owner->Member()) {
71                 $email = $member->Email;
72             }
73         }
74         return $email;
75     }
76     
77 }
78 
79 // Декоратор SiteConfig для этого типа уведомлений
80 class ClientEmailOrderNotification_SiteConfig extends SiteConfigDecorator {
81     function extraStatics() {
82         return array(
83             'db' => array(                
84                 'ClientEmailOrderNotificationActive' => 'Boolean', // активность
85             )
86         );
87     }
88     public function updateCMSFields(FieldSet &$fields) {            
89         $tab = self::get_config_tab($fields, 'OrderNotifications.EmailOrderNotification');              
90         $tab->push(new CheckboxField('ClientEmailOrderNotificationActive', $this->owner->FieldLabel('ClientEmailOrderNotificationActive')));
91     }
92 }
93 
[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