本文整理汇总了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);
}
}
}
}
}
示例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();
}
}
}
}
示例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);
}
}
}