當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Varien_Event_Observer::getSource方法代碼示例

本文整理匯總了PHP中Varien_Event_Observer::getSource方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getSource方法的具體用法?PHP Varien_Event_Observer::getSource怎麽用?PHP Varien_Event_Observer::getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Varien_Event_Observer的用法示例。


在下文中一共展示了Varien_Event_Observer::getSource方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: observe

 /**
  * @param Varien_Event_Observer $observer
  * @event sales_quote_merge_before
  */
 public function observe(Varien_Event_Observer $observer)
 {
     /** @var Aleron75_UnmergedCart_Helper_Data $h */
     $h = Mage::helper('aleron75_unmergedcart');
     if (!$h->isActive()) {
         return;
     }
     /** @var Mage_Sales_Model_Quote $customerQuote */
     $customerQuote = $observer->getQuote();
     /** @var Mage_Sales_Model_Quote $sessionQuote */
     $sessionQuote = $observer->getSource();
     if ($customerQuote->getId() && $sessionQuote->getId() != $customerQuote->getId()) {
         /** @var Mage_Sales_Model_Quote $discardableQuote */
         $discardableQuote = $h->isKeepSessionCart() ? $customerQuote : $sessionQuote;
         /** @var Mage_Sales_Model_Quote_Item $item */
         foreach ($discardableQuote->getAllItems() as $item) {
             $item->isDeleted(true);
             if ($item->getHasChildren()) {
                 /** @var Mage_Sales_Model_Quote_Item_Abstract $child */
                 foreach ($item->getChildren() as $child) {
                     $child->isDeleted(true);
                 }
             }
         }
     }
 }
開發者ID:aleron75,項目名稱:unmergedcart,代碼行數:30,代碼來源:PreventMergeQuote.php

示例2: truncateCustomerCart

 /**
  * Truncate the customer's cart if active
  * @access public
  * @return void
  */
 public function truncateCustomerCart(Varien_Event_Observer $observer)
 {
     if (Mage::helper('jbh_cartmerge')->isActive()) {
         if ($observer->getSource()->hasItems() || Mage::helper('jbh_cartmerge')->cleanIfEmpty()) {
             if (is_object($observer->getQuote()) && $observer->getQuote()->getId()) {
                 $observer->getQuote()->removeAllItems();
             }
         }
     }
 }
開發者ID:ricci69,項目名稱:jbh_cartmerge,代碼行數:15,代碼來源:Observer.php

示例3: salesQuoteMergeBefore

 /**
  * Remove products that are in the cart that where not hidden while logged out
  * but are hidden to the customer once logged in.
  *
  * @param Varien_Event_Observer $observer
  */
 public function salesQuoteMergeBefore(Varien_Event_Observer $observer)
 {
     /** @var Mage_Sales_Model_Quote $guestQuote */
     $guestQuote = $observer->getSource();
     // If a hidden product is loaded, it's entity_id is set to null.
     // So all we need to do here is set the deleted property to true,
     // and then they will not be merged into the customer quote.
     foreach ($guestQuote->getItemsCollection() as $quoteItem) {
         if (!$quoteItem->getProductId()) {
             $quoteItem->isDeleted(true);
         }
     }
 }
開發者ID:aniljaiswal,項目名稱:order-confirmation,代碼行數:19,代碼來源:Observer.php


注:本文中的Varien_Event_Observer::getSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。