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


PHP Varien_Event_Observer::getCart方法代碼示例

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


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

示例1: updateItemInCart

 public function updateItemInCart(Varien_Event_Observer $observer)
 {
     if ($this->_isEnabled && $this->_email && Mage::getStoreConfig('sailthru/email/abandoned_cart')) {
         try {
             if ($hasChanges = $observer->getCart()->hasDataChanges()) {
                 $response = Mage::getModel('sailthruemail/client_purchase')->sendCart($observer->getCart()->getQuote(), $this->_email, 'updateItemInCart');
             }
         } catch (Exception $e) {
             Mage::logException($e);
         }
         return $this;
     }
 }
開發者ID:xiaoguizhidao,項目名稱:sailthru-magento-extension,代碼行數:13,代碼來源:Purchase.php

示例2: initCart

 public function initCart(Varien_Event_Observer $observer)
 {
     if (Mage::getStoreConfig('saferpaycw/general/cancel_existing_orders')) {
         $cart = $observer->getCart();
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $query = 'SELECT product_id FROM sales_flat_quote_item WHERE quote_id = ' . $cart->getQuote()->getId();
         $resource = Mage::getSingleton('core/resource');
         $conn = $resource->getConnection('core_read');
         $productIds = $conn->query($query)->fetchAll();
         $orders = Mage::getResourceModel('sales/order_collection')->addAttributeToSelect('*')->addAttributeToFilter('customer_id', $customer->getId())->addAttributeToFilter('status', Customweb_SaferpayCw_Model_Method::SAFERPAYCW_STATUS_PENDING)->load();
         if (count($orders) > 0 && count($productIds) > 0) {
             foreach ($productIds as $productId) {
                 $product = Mage::getModel('catalog/product')->load($productId);
                 if (!$product->isSalable()) {
                     foreach ($orders as $order) {
                         $order->cancel();
                         $order->setIsActive(0);
                         $order->addStatusToHistory(Customweb_SaferpayCw_Model_Method::SAFERPAYCW_STATUS_CANCELED, Mage::helper('SaferpayCw')->__('Order cancelled, because the customer was too long in the payment process of Saferpay.'));
                         $order->save();
                     }
                     break;
                 }
             }
         }
     }
 }
開發者ID:jronatay,項目名稱:ultimo-magento-jron,代碼行數:26,代碼來源:Observer.php

示例3: updatedItemsQtyValidate

 public function updatedItemsQtyValidate(Varien_Event_Observer $observer)
 {
     if (!Mage::helper('aitunits')->getAvailableStores()) {
         return false;
     }
     /* {#AITOC_COMMENT_END#}
        $performer = Aitoc_Aitsys_Abstract_Service::get()->platform()->getModule('Aitoc_Aitunits')->getLicense()->getPerformer();
        $ruler = $performer->getRuler();
        $groupId = Mage::app()->getGroup()->getId();
        if(!in_array($groupId, $ruler->getAvailableStores()))
        {
            return false;
        }
        {#AITOC_COMMENT_START#} */
     $cart = $observer->getCart();
     $info = $observer->getInfo();
     foreach ($info as $itemId => $itemInfo) {
         if (!isset($itemInfo['qty'])) {
             continue;
         }
         $item = $cart->getQuote()->getItemById($itemId);
         $this->_summQty = $item->getQty();
         $item = Mage::helper('aitunits')->getValidProduct($item);
         if ($item->getProductType() == 'simple' || 'virtual' || 'configurable') {
             $this->_validateProduct($item, $itemInfo['qty']);
         }
     }
 }
開發者ID:finelinePG,項目名稱:finelink-dev,代碼行數:28,代碼來源:Cart.php

示例4: checkoutCartSaveAfter

 /**
  * Updates the stock quantity for the item in MongoDB.
  *
  * @param Varien_Event_Observer $event
  * @return Hackathon_MongoOrderTransactions_Model_Observer
  */
 public function checkoutCartSaveAfter(Varien_Event_Observer $observer)
 {
     $quote = $observer->getCart()->getQuote();
     $mongodb = Mage::getModel('hackathon_ordertransaction/mongo');
     $mongodb->loadQuote($quote->getId());
     $mongodb->setQuoteId($quote->getId());
     $mongodb->setItems(array());
     foreach ($quote->getAllItems() as $item) {
         $mongodb->addItem($item->getProductId(), $item->getQty());
     }
     $mongodb->saveQuote();
     return $this;
 }
開發者ID:eniuz,項目名稱:MongoDB-OrderTransactions,代碼行數:19,代碼來源:Observer.php

示例5: sendAbandonedCart

 public function sendAbandonedCart(Varien_Event_Observer $observer)
 {
     $customer = $observer->getEvent()->getCustomer();
     if ($this->_isEnabled && $customer->getEmail()) {
         try {
             $cart = $observer->getCart();
             $response = Mage::getModel('sailthruemail/client_purchase_abandoned')->sendCart($cart, $customer->getEmail());
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     return $this;
 }
開發者ID:xiaoguizhidao,項目名稱:sailthru-magento-extension,代碼行數:13,代碼來源:Abandoned.php

示例6: applyDiscounts

 public function applyDiscounts(Varien_Event_Observer $observer)
 {
     foreach ($observer->getCart()->getQuote()->getAllVisibleItems() as $item) {
         if ($item->getParentItem()) {
             $item = $item->getParentItem();
         }
         // Discounted 25% off
         $percentDiscount = 0.25;
         // This makes sure the discount isn't applied over and over when refreshing
         $specialPrice = $item->getPrice() - $item->getPrice() * $percentDiscount;
         // Make sure we don't have a negative
         if ($specialPrice > 0) {
             $item->setCustomPrice($specialPrice);
             $item->setOriginalCustomPrice($specialPrice);
             $item->getProduct()->setIsSuperMode(true);
         }
     }
 }
開發者ID:EliasZ,項目名稱:CustomDiscount,代碼行數:18,代碼來源:Observer.php

示例7: checkoutCartSaveBefore

 /**
  * Set available quantity to quote item
  *
  * @param Varien_Event_Observer $observer observed object
  */
 public function checkoutCartSaveBefore(Varien_Event_Observer $observer)
 {
     $model = Mage::getModel('catalog/product');
     $helper = Mage::helper('dailydeals');
     $cartItems = $observer->getCart()->getItems();
     foreach ($cartItems as $cartItem) {
         $product = $model->load($cartItem->getProductId());
         if ($helper->isDealEnabled($product)) {
             if ($product->getDealQty() < $cartItem->getQty()) {
                 $cartItem->setQty($product->getDealQty());
                 Mage::getSingleton('core/session')->addError($helper->__('Only ' . $product->getDealQty() . ' deal "' . $product->getName() . '" left.'));
             }
         }
     }
 }
開發者ID:DeveshKumarThakur,項目名稱:cosmetics,代碼行數:20,代碼來源:Observer.php

示例8: checkoutCartProductUpdateAfter

 /** 
  * Check do not allow update quantity product gift
  * Event checkout_cart_update_items_after
  * @var items
  */
 public function checkoutCartProductUpdateAfter(Varien_Event_Observer $observer)
 {
     // Ensure cart is not empty.
     $session = Mage::getSingleton('checkout/session');
     $OriginSocialGiftIds = $session->getOriginSocialGiftIds() ? $session->getOriginSocialGiftIds() : array();
     $items = $observer->getCart()->getQuote()->getAllVisibleItems();
     foreach ($items as $item) {
         if ($item->getQty() > 1 && in_array($item->getProduct()->getId(), $OriginSocialGiftIds)) {
             $qty = "1";
             $item->setQty($qty);
             Mage::getSingleton('core/session')->addError(Mage::helper('mw_socialgift')->__('The quantity of Social Gift is limited. You can not update the quantity of gift greater than 1.'));
             $item->getProduct()->setIsSuperMode(TRUE);
         }
     }
 }
開發者ID:GaynorH,項目名稱:prestigedrinks,代碼行數:20,代碼來源:Observer.php

示例9: updateCustomPrice

 public function updateCustomPrice(Varien_Event_Observer $observer)
 {
     $cart = $observer->getCart()->getQuote()->getAllVisibleItems();
     $this->updateCart($cart);
 }
開發者ID:sivaanil,項目名稱:paytech,代碼行數:5,代碼來源:Observer.php

示例10: resetOverridingPrices

 /**
  * Reset prices which have been overridden in the shopping cart.
  *
  * @param Varien_Event_Observer $observer
  */
 public function resetOverridingPrices(Varien_Event_Observer $observer)
 {
     if (Mage::helper('ddq')->isEnabled()) {
         // array of requested items (grouped products for example adds several items at the same time)
         $items = $observer->getCart()->getQuote()->getAllVisibleItems();
         if (count($items)) {
             foreach ($items as $item) {
                 if (!$item->getParentItem()) {
                     $item->setCustomPrice(null)->setOriginalCustomPrice(null);
                 }
             }
         }
     }
 }
開發者ID:finelinePG,項目名稱:finelink-dev,代碼行數:19,代碼來源:Observer.php

示例11: updateCart

 public function updateCart(Varien_Event_Observer $observer)
 {
     if (Mage::getStoreConfig('deals/general/enabled')) {
         $quote = $observer->getCart()->getQuote();
         $items = $quote->getAllVisibleItems();
         foreach ($items as $item) {
             if ($item->getParentItem()) {
                 $item = $item->getParentItem();
             }
             $productId = $item->getProductId();
             $qty = $item->getQty();
             $deal = Mage::getModel('deals/deals')->getCollection()->addFieldToFilter('product_id', $productId)->addFieldToFilter('status', 2)->getFirstItem();
             if ($deal->getId()) {
                 $dealQty = $deal->getMaxDealQty();
                 if ($dealQty != '') {
                     if ($qty > $dealQty) {
                         $price = $deal->getPrice();
                         $specialPrice = $deal->getSpecialPrice();
                         $dealPrice = $price - $specialPrice;
                         $price = $item->getProduct()->getFinalPrice() + $dealPrice;
                     } else {
                         $price = $deal->getSpecialPrice();
                     }
                     $item->setCustomPrice($price);
                     $item->setOriginalCustomPrice($price);
                     $item->getProduct()->setIsSuperMode(true);
                 }
             }
         }
     }
 }
開發者ID:ramantalkin,項目名稱:tmp01skin,代碼行數:31,代碼來源:Observer.php


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