当前位置: 首页>>代码示例>>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;未经允许,请勿转载。