本文整理汇总了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;
}
}
示例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;
}
}
}
}
}
示例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']);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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.'));
}
}
}
}
示例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);
}
}
}
示例9: updateCustomPrice
public function updateCustomPrice(Varien_Event_Observer $observer)
{
$cart = $observer->getCart()->getQuote()->getAllVisibleItems();
$this->updateCart($cart);
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}