User Tools

Site Tools


koding:hostcms:siteuser

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

koding:hostcms:siteuser [06.05.15 в 18:29]
Артем Куц создано
— (current)
Line 1: Line 1:
-<​code><?​php 
  
- ​defined('​HOSTCMS'​) || exit('​HostCMS:​ access denied.'​);​ 
-  
-/** 
-* Отслеживание смены статуса 
- 
- 
- ​Core_Event::​attach('​shop_order.onBeforeSave',​ array('​Shop_Order_Changestatus',​ '​onBeforeSave'​));​ 
- 
-* @author Kuts Artem, KAD Systems (©) 2014  
-* @date 19-08-2014  
-*/ 
- 
- class Shop_Order_Changestatus 
- { 
-    static public function onBeforeSave($object,​ $operation) 
-    { 
- $oOrder = Core_Entity::​factory("​shop_order",​ $object->​id);​ 
-  
- // Смена статуса произошла 
- if ($oOrder->​shop_order_status_id != $object->​shop_order_status_id && !$oOrder->​paid) ​ 
- { 
- if ($object->​shop_order_status_id == 2 && $object->​shop_payment_system_id > 1) 
- { 
- // Отсылаем письмо со ссылкой 
- $oXsl = Core_Entity::​factory('​Xsl'​)->​getByName(DEFPAY_CASHLESS_PAYLINK_MAIL);​ 
-  
- $oShopOrder = $object; 
- $oShop = $oShopOrder->​Shop;​ 
- 
- $to = $oShopOrder->​email;​ 
- 
- if (Core_Valid::​email($to)) 
- { 
- // Адрес "ОТ КОГО"​ для пользователя 
- $from = $oShop->​getFirstEmail();​ 
-  
- $oShop 
- ->​addEntity($oShop->​Shop_Company) 
- ->​addEntity( 
- $oShop->​Site->​clearEntities()->​showXmlAlias() 
- ) 
- ->​addEntity( 
- $oShopOrder->​clearEntities() 
- ->​showXmlCurrency(TRUE) 
- ->​showXmlCountry(TRUE) 
- ->​showXmlItems(TRUE) 
- ->​showXmlDelivery(TRUE) 
- ->​showXmlPaymentSystem(TRUE) 
- ->​showXmlOrderStatus(TRUE) 
- ->​showXmlProperties(TRUE) 
- ->​showXmlSiteuser(TRUE) 
- ); 
-  
- $sXml = $oShop->​getXml();​ 
- 
- //echo "<​pre>"​ . htmlspecialchars($sXml) . "</​pre>";​ 
- $return = Xsl_Processor::​instance() 
- ->​xml($sXml) 
- ->​xsl($oXsl) 
- ->​process();​ 
- 
- $sInvoice = $return; 
- $sInvoice = str_replace(">",​ ">​\n",​ $sInvoice); 
- 
- // Тема письма пользователю 
- $user_subject = "​Информация для оплаты заказа";​ 
- 
- Core_Mail::​instance() 
- ->​from($from) 
- ->​to($to) 
- ->​subject($user_subject) 
- ->​message($sInvoice) 
- ->​contentType('​text/​html'​) 
- ->​header('​X-HostCMS-Reason',​ '​OrderConfirm'​) 
- ->​header('​Precedence',​ '​bulk'​) 
- ->​send();​ 
- } 
- } 
- } 
- } 
-}</​code>​ 
koding/hostcms/siteuser.1430926187.txt.gz · Last modified: 26.06.15 в 15:05 (external edit)