本文整理匯總了PHP中Varien_Event_Observer::getItem方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getItem方法的具體用法?PHP Varien_Event_Observer::getItem怎麽用?PHP Varien_Event_Observer::getItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getItem方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: salesruleProcess
/**
* Calculate discounts by sales rules
* @param Varien_Event_Observer $observer
*/
public function salesruleProcess($observer)
{
$quote = $observer->getQuote();
$address = $observer->getAddress();
$rule = $observer->getRule();
$discounts = @unserialize($quote->getAuctaneapiDiscounts());
if (!self::$_counter) {
$discounts = array();
$address->setBaseShippingDiscountAmount(0);
self::$_counter++;
}
if (!isset(self::$_shippingAmountProcessed[$rule->getId()]) && $address->getShippingAmount()) {
$shippingAmount = $address->getShippingAmountForDiscount();
if ($shippingAmount !== null) {
$baseShippingAmount = $address->getBaseShippingAmountForDiscount();
} else {
$baseShippingAmount = $address->getBaseShippingAmount();
}
//check for discount applied on shipping amount or not
if (!$rule['apply_to_shipping']) {
$baseShippingAmount = 0;
}
$baseDiscountAmount = 0;
$rulePercent = min(100, $rule->getDiscountAmount());
switch ($rule->getSimpleAction()) {
case Mage_SalesRule_Model_Rule::TO_PERCENT_ACTION:
$rulePercent = max(0, 100 - $rule->getDiscountAmount());
case Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION:
$baseDiscountAmount = ($baseShippingAmount - $address->getBaseShippingDiscountAmount()) * $rulePercent / 100;
break;
case Mage_SalesRule_Model_Rule::TO_FIXED_ACTION:
$baseDiscountAmount = $baseShippingAmount - $rule->getDiscountAmount();
break;
case Mage_SalesRule_Model_Rule::BY_FIXED_ACTION:
$baseDiscountAmount = $rule->getDiscountAmount();
break;
case Mage_SalesRule_Model_Rule::CART_FIXED_ACTION:
self::$_cartRules = $address->getCartFixedRules();
if (!isset(self::$_cartRules[$rule->getId()])) {
self::$_cartRules[$rule->getId()] = $rule->getDiscountAmount();
}
if (self::$_cartRules[$rule->getId()] > 0) {
$baseDiscountAmount = min($baseShippingAmount - $address->getBaseShippingDiscountAmount(), self::$_cartRules[$rule->getId()]);
self::$_cartRules[$rule->getId()] -= $baseDiscountAmount;
}
break;
}
$ruleDiscount = 0;
$left = $baseShippingAmount - ($address->getBaseShippingDiscountAmount() + $baseDiscountAmount);
if ($left >= 0) {
$ruleDiscount = $baseDiscountAmount;
}
$discounts[$rule->getId() . '-' . $observer->getItem()->getId() . '-' . uniqid()] = $observer->getResult()->getBaseDiscountAmount() + $ruleDiscount;
$address->setBaseShippingDiscountAmount(min($address->getBaseShippingDiscountAmount() + $baseDiscountAmount, $baseShippingAmount));
self::$_shippingAmountProcessed[$rule->getId()] = true;
} else {
$discounts[$rule->getId() . '-' . $observer->getItem()->getId() . '-' . uniqid()] = $observer->getResult()->getBaseDiscountAmount();
}
$quote->setAuctaneapiDiscounts(@serialize($discounts));
}
示例2: salesConvertQuoteItemToOrderItem
public function salesConvertQuoteItemToOrderItem(Varien_Event_Observer $observer)
{
$quoteItem = $observer->getItem();
if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
$orderItem = $observer->getOrderItem();
$options = $orderItem->getProductOptions();
$options['additional_options'] = unserialize($additionalOptions->getValue());
$orderItem->setProductOptions($options);
}
}
示例3: addSubscriptionProductSubscriptionToOrder
/**
* Save additional (subscription) product options (added in addSubscriptionProductSubscriptionToQuote)
* from quote items to order items
*
* @event sales_convert_quote_item_to_order_item
* @param Varien_Event_Observer $observer
*/
public function addSubscriptionProductSubscriptionToOrder(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
/** @noinspection PhpUndefinedMethodInspection */
$quoteItem = $observer->getItem();
/** @var Mage_Sales_Model_Order_Item $orderItem */
/** @noinspection PhpUndefinedMethodInspection */
$orderItem = $observer->getOrderItem();
if ($additionalOptions = $quoteItem->getOptionByCode('additional_options')) {
$options = $orderItem->getProductOptions();
$options['additional_options'] = unserialize($additionalOptions->getValue());
$orderItem->setProductOptions($options);
}
}
示例4: salesOrderItemCancel
/**
* Change deal_qty and deal_bought when item cancel
*
* @param Varien_Event_Observer $observer observed object
*/
public function salesOrderItemCancel(Varien_Event_Observer $observer)
{
$item = $observer->getItem();
if ($item->getDealStat()) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$product->setDealQty($product->getDealQty() + $item->getQtyOrdered())->setDealBought($product->getDealBought() - $item->getQtyOrdered())->save();
}
}
示例5: catalogInventorySave
public function catalogInventorySave(Varien_Event_Observer $observer)
{
$product = $observer->getItem();
$this->updateStock($product->getProductId());
}
示例6: checkoutCartUpdateItemComplete
/**
* Listener to update $this->_lastUpdatedItem.
* @param Varien_Event_Observer $observer
* @return void
*/
public function checkoutCartUpdateItemComplete(Varien_Event_Observer $observer)
{
$this->_lastUpdatedItem = $observer->getItem();
}
示例7: refreshDdqCache
/**
* Refresh stock related ddq cache when saving a stock item.
*
* @param Varien_Event_Observer $observer
*/
public function refreshDdqCache(Varien_Event_Observer $observer)
{
if ($observer && $observer->getItem() && $observer->getItem()->getProduct()) {
Mage::helper('ddq/cache')->clean(array('tag' => Mage_Catalog_Model_Product::CACHE_TAG . '_' . $observer->getItem()->getProduct()->getId()));
}
}
示例8: updateCartReservation
/**
* When product is added to shopping cart add an entry to reservationquotes with reservation data
* @param Varien_Event_Observer $event
*
* @return $this
*/
public function updateCartReservation(Varien_Event_Observer $event)
{
/** @var $quoteItem Mage_Sales_Model_Quote_Item */
$quoteItem = $event->getItem();
/** @var $product Mage_Catalog_Model_Product */
$product = $quoteItem->getProduct();
$source = unserialize($product->getCustomOption('info_buyRequest')->getValue());
if ($this->excludedFromUpdate($quoteItem, $source)) {
return $this;
}
list($startDateArr, $endDateArr) = ITwebexperts_Payperrentals_Helper_Data::getStartEndDates($source);
foreach ($startDateArr as $count => $startDate) {
$endDate = $endDateArr[$count];
if ($quoteItem->getProductType() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) {
$qty = $this->getSelectedQtyByTheCustomerForTheProduct($product, $quoteItem);
$product = $this->getProduct($product, $source);
if ($quoteItem->getProductType() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE) {
Mage::getResourceModel('payperrentals/reservationquotes')->deleteByQuoteItemAndDates($quoteItem, $startDate, $endDate);
$this->saveSimpleReservationProduct($quoteItem, $product, $source, $qty, $startDate, $endDate);
}
$this->saveConfigurableReservationProduct($quoteItem, $product, $source, $qty, $startDate, $endDate);
} else {
$qty = $this->getSelectedQtyByTheCustomerForTheProduct($product, $quoteItem);
ITwebexperts_Payperrentals_Helper_Data::createQuantities($source, $qty, true);
$selectionIds = $source['bundle_option'];
$selections = $product->getTypeInstance(true)->getSelectionsByIds($selectionIds, $product);
Mage::getResourceModel('payperrentals/reservationquotes')->deleteByQuoteItemAndDates($quoteItem, $startDate, $endDate);
foreach ($selections->getItems() as $selection) {
if ($selection->getTypeId() == ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE) {
$qty = ITwebexperts_Payperrentals_Helper_Data::getQuantityForSelectionProduct($selection, $qty);
$this->saveSimpleReservationProduct($quoteItem, $selection, $source, $qty, $startDate, $endDate);
}
}
}
}
return $this;
}
示例9: addOptionHashToSession
/**
* Add item option hash to checkout session. This is for comparison
* checks when adding new items to the cart in order to determine
* which item the requested one should be merged with, if any.
*
* @param Varien_Event_Observer $observer
*/
public function addOptionHashToSession(Varien_Event_Observer $observer)
{
if (Mage::helper('ddq')->isEnabled()) {
try {
if ($observer->getItem() && $observer->getItem()->getId()) {
// retrieve cart item option hash as separation identification
$optionHash = Mage::helper('ddq')->getCartItemOptionHash($observer->getItem(), array('info_buyRequest', 'ddq_identifier'));
if (!is_null($optionHash)) {
// retrieve stored option hash / item id pairings for comparison check
$optionHashTable = Mage::getSingleton('checkout/session')->getData(self::OPTION_HASH_TABLE_KEY);
if (!is_array($optionHashTable)) {
$optionHashTable = array();
}
if (!isset($optionHashTable[$optionHash])) {
$optionHashTable[$optionHash] = array();
}
foreach ($optionHashTable as &$ids) {
if (($key = array_search($observer->getItem()->getId(), $ids)) !== false) {
unset($ids[$key]);
}
}
// add the option hash to the table
$optionHashTable[$optionHash][] = $observer->getItem()->getId();
// re-save the table in the session
Mage::getSingleton('checkout/session')->setData(self::OPTION_HASH_TABLE_KEY, $optionHashTable);
}
}
} catch (Exception $e) {
Mage::helper('ddq')->log($e);
}
}
}
示例10: mtmProductModifyUpdateItem
/**
* change product price for mtm products (made to measure)
*
* @param Varien_Event_Observer $observer
*/
public function mtmProductModifyUpdateItem(Varien_Event_Observer $observer)
{
$item = $observer->getItem();
$this->_mtmProductModifyPrice($item);
}