本文整理汇总了PHP中Varien_Event_Observer::getQuoteItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Event_Observer::getQuoteItem方法的具体用法?PHP Varien_Event_Observer::getQuoteItem怎么用?PHP Varien_Event_Observer::getQuoteItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getQuoteItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_price
public function update_price(Varien_Event_Observer $observer)
{
$quote_item = $observer->getQuoteItem();
$item = Mage::getModel('catalog/product')->load($quote_item->getProduct()->getId());
//echo ' '.$item->getId()."==".$quote_item->getProduct()->getQty().' '.$item->getData('minqtyforfreeshipping').' '.$item->getData('shippingcost');
//exit;
echo $quote_item->getProduct()->getId() . "==" . $quote_item->getProduct()->getQty() . "==" . $item->getData('minqtyforfreeshipping');
exit;
if ($quote_item->getProduct()->getQty() < $item->getData('minqtyforfreeshipping')) {
$special_price = $item->getFinalPrice();
/*if(!$special_price || $special_price == 0.00){
$special_price = number_format($item->getPrice(),2);
}*/
$extra_price = $item->getData('shippingcost') / $quote_item->getProduct()->getQty();
$final_unit_price = number_format($special_price + $extra_price, 2);
$quote_item->setCustomPrice($final_unit_price);
$quote_item->setOriginalCustomPrice($final_unit_price);
$quote_item->getProduct()->setIsSuperMode(true);
} else {
$quote_item->setCustomPrice($special_price);
$quote_item->setOriginalCustomPrice($special_price);
$quote_item->getProduct()->setIsSuperMode(true);
}
return $this;
}
示例2: salesQuoteItemSetCustomAttribute
public function salesQuoteItemSetCustomAttribute(Varien_Event_Observer $observer)
{
$item = $observer->getQuoteItem();
$product = $observer->getProduct();
$categories = $observer->getProduct()->getCategoryIds();
//$item = Mage::getSingleton('checkout/session')->getQuote()->getItemByProduct($product);
$price = $observer->getEvent()->getQuoteItem()->getPrice();
$name = $observer->getEvent()->getQuoteItem()->getName();
$qty = $observer->getEvent()->getQuoteItem()->getQty();
$id = $observer->getEvent()->getQuoteItem()->getProductId();
$sku = $observer->getEvent()->getQuoteItem()->getSku();
$pid = Mage::getModel('catalog/product')->getResource()->getIdBySku($sku);
$foundProduct = Mage::getModel('catalog/product')->load($pid);
$price = $foundProduct->getPrice();
$specialprice = $foundProduct->getSpecialPrice();
$total_amount_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/freeshippingtotal');
$total_minimum_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/minimumshippingamount');
$total_each_setting = Mage::getStoreConfig('payumoneycharge/payumoneycharge_group/shipamounteach');
/*if(in_array(165,$categories) || in_array(141,$categories))
{
$product = Mage::getSingleton('catalog/product')->load($id);
$moq = $product->getMinqtyforfreeshipping();
$shippingcost = $product->getShippingcost();
$extraShippingCost = $moq - $qty * $shippingcost;
$item->setExtraShipping($extraShippingCost);
Mage::log("Bulk Shipping Charges:".$extraShippingCost);
}
else */
if (in_array(154, $categories) || in_array(155, $categories) || in_array(156, $categories) || in_array(160, $categories) || in_array(163, $categories) || in_array(182, $categories) || in_array(188, $categories) || in_array(189, $categories) || in_array(180, $categories) || in_array(215, $categories)) {
$product = Mage::getSingleton('catalog/product')->load($id);
$shippingcost = $product->getShippingcost();
$extraShippingCost = 0;
$item->setExtraShipping($extraShippingCost);
Mage::log("Civil Shipping Charges:" . $extraShippingCost);
} else {
if ($specialprice) {
$row_total = $specialprice * $qty;
} else {
$row_total = $price * $qty;
}
if ($row_total >= 200) {
if ($specialprice) {
$cartGrossTotal = $specialprice * $qty;
} else {
$cartGrossTotal = $price * $qty;
}
$grand = $cartGrossTotal;
$gtotal = (int) $grand / 100;
$noofhun = (int) $gtotal - 1;
$timesofhun = $total_minimum_setting + $noofhun * $total_each_setting;
} else {
$timesofhun = $total_minimum_setting;
}
$item->setShippingCost($timesofhun);
Mage::log("Non Bulk Shipping Charges:" . $timesofhun);
//Mage::log("Product Id:".$name);
//Mage::log("Product Id:".$id);
}
}
示例3: removeItemFromCart
public function removeItemFromCart(Varien_Event_Observer $observer)
{
if ($this->_isEnabled && $this->_email) {
try {
$response = Mage::getModel('sailthruemail/client_purchase')->sendCart($observer->getQuoteItem()->getQuote(), $this->_email, 'removeItemFromCart');
} catch (Exception $e) {
Mage::logException($e);
}
return $this;
}
}
示例4: onSalesQuoteDelete
public function onSalesQuoteDelete(Varien_Event_Observer $_observer)
{
//delete tha free product yo.
$_cartHelper = Mage::helper('checkout/cart');
$_item = $_observer->getQuoteItem();
if (in_array($_item->getSku(), $this->_promoTriggers)) {
$_deletePromoSku = $_item->getSku() . $this->_freeProductSkuSuffix;
foreach (Mage::getModel('checkout/session')->getQuote()->getAllItems() as $_item) {
if ($_item->getSku() == $_deletePromoSku) {
$_cartHelper->getCart()->removeItem($_item->getItemId())->save();
}
}
}
}
示例5: setCustomPrice
public function setCustomPrice(Varien_Event_Observer $obs)
{
$item = $obs->getQuoteItem();
$item = $item->getParentItem() ? $item->getParentItem() : $item;
// $product=$item->getProduct();
$helper = Mage::helper('catalog/product_configuration');
$options = $helper->getCustomOptions($item);
if ($options[3]['value'] == "custom") {
$price = (double) Mage::getSingleton('core/session')->getCustomPrice();
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
// Enable super mode on the product.
$item->getProduct()->setIsSuperMode(true);
}
}
示例6: modifyPrice
public function modifyPrice(Varien_Event_Observer $obs)
{
// Get the quote item
$item = $obs->getQuoteItem();
//echo "<pre>";
//var_dump($item);
// Ensure we have the parent item, if it has one
$item = $item->getParentItem() ? $item->getParentItem() : $item;
// Load the custom price
$price = $this->_getPriceByItem($item);
$qty = $this->_getQtyByItem($item);
//$price = "5.00";
// Set the custom price
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
// Enable super mode on the product.
$item->getProduct()->setIsSuperMode(true);
}
示例7: applyDiscount
public function applyDiscount(Varien_Event_Observer $observer)
{
/* @var $item Mage_Sales_Model_Quote_Item */
$item = $observer->getQuoteItem();
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->getProduct()->getPrice() - $item->getProduct()->getPrice() * $percentDiscount;
// Make sure we don't have a negative
if ($specialPrice > 0) {
$item->setCustomPrice($specialPrice);
$item->setOriginalCustomPrice($specialPrice);
$item->getProduct()->setIsSuperMode(true);
}
}
示例8: addToCartTracking
/**
* Observer method.
* Sends information to FACT-Finder if item was added to cart.
*
* @param Varien_Event_Observer $observer
*
* @return void
*/
public function addToCartTracking($observer)
{
if (!Mage::getStoreConfigFlag('factfinder/export/track_carts') || !Mage::helper('factfinder')->isEnabled('tracking')) {
return;
}
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
$quoteItem = $observer->getQuoteItem();
/** @var Mage_Catalog_Model_Product $product */
$product = $observer->getProduct();
$idFieldName = Mage::helper('factfinder_tracking')->getIdFieldName();
$qty = $quoteItem->getQty();
$customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
if ($customerId) {
$customerId = md5('customer_' . $customerId);
}
try {
/** @var $tracking FACTFinder_Tracking_Model_Handler_Tracking */
$tracking = Mage::getModel('factfinder_tracking/handler_tracking');
$tracking->trackCart($quoteItem->getProductId(), $product->getData($idFieldName), $product->getName(), null, Mage::helper('factfinder_tracking')->getSessionId(), null, $qty, $product->getFinalPrice($qty), $customerId);
} catch (Exception $e) {
Mage::helper('factfinder/debug')->log($e->getMessage());
}
}
示例9: changePrice
public function changePrice(Varien_Event_Observer $observer)
{
$sku = $observer->getEvent()->getQuoteItem()->getProduct()->getData('sku');
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$new_price = $_product->getPrice();
// Get the quote item
$item = $observer->getQuoteItem();
// Ensure we have the parent item, if it has one
$item = $item->getParentItem() ? $item->getParentItem() : $item;
//apply the payment logic on in configurable products only
if ($item->getProduct()->isConfigurable()) {
// Load the custom price
$price = $new_price;
// Set the custom price
//Set price by subtracting base price from the passed price and
//then adding the product price to tackle any extra price attached with custom options :)
//identify if there is some extra cost, final price - base price
$extra_price = $item->getProduct()->getFinalPrice() - $item->getProduct()->getPrice();
//add this extra price
$extra_price = $extra_price > 0 ? $extra_price : 0;
/* echo "Got:". $price;
echo " Extra: ".$extra_price;
echo "final price:".$item->getProduct()->getFinalPrice().", price:".$item->getProduct()->getPrice().", Passed:".($extra_price + $price);die(); */
//only apply the associated price if extra_price don't exist (means values are not being set with attributes)
/*if($extra_price == 0) {
$item->setCustomPrice($extra_price + $price);
$item->setOriginalCustomPrice($extra_price + $price);
}else {*/
//if the attributes are defined, use the parent product price instead (base product price)
$item->setCustomPrice($item->getProduct()->getFinalPrice());
$item->setOriginalCustomPrice($item->getProduct()->getFinalPrice());
//}
// Enable super mode on the product.
$item->getProduct()->setIsSuperMode(true);
}
}
示例10: removeReservationFromCart
/**
* Event fired when a product is removed from the cart
* @param Varien_Event_Observer $event
*
* @return $this
*/
public function removeReservationFromCart(Varien_Event_Observer $event)
{
/** @var $quoteItem Mage_Sales_Model_Quote_Item*/
$quoteItem = $event->getQuoteItem();
if (!$quoteItem) {
$quoteItem = $event->getItem();
}
if ($quoteItem->getProductType() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE && $quoteItem->getProductType() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_CONFIGURABLE && $quoteItem->getProductType() != ITwebexperts_Payperrentals_Helper_Data::PRODUCT_TYPE_BUNDLE) {
return $this;
}
$aChildQuoteItems = Mage::getModel("sales/quote_item")->getCollection()->setQuote($quoteItem->getQuote())->addFieldToFilter("parent_item_id", $quoteItem->getId());
Mage::getResourceModel('payperrentals/reservationquotes')->deleteByQuoteItem($quoteItem);
foreach ($aChildQuoteItems as $cItems) {
Mage::getResourceModel('payperrentals/reservationquotes')->deleteByQuoteItem($cItems);
}
if ($quoteItem->getQuote()->getItemsCount() == 1) {
Mage::getSingleton('checkout/session')->setIsExtendedQuote(false);
}
return $this;
}
示例11: checkProductInSocialGift
/**
* Check product id was removed by user in cart, if it is a gift, add it to list gift again.
* @var item
*/
public function checkProductInSocialGift(Varien_Event_Observer $observer)
{
$infoRequest = array();
$session = Mage::getSingleton('checkout/session');
$OriginSocialGiftIds = $session->getOriginSocialGiftIds() ? $session->getOriginSocialGiftIds() : array();
$quoteItem = $observer->getQuoteItem();
$quoteItem = $quoteItem->getParentItem() ? $quoteItem->getParentItem() : $quoteItem;
$product_id = $quoteItem->getProduct()->getId();
$SocialProductShared = $session->getSocialProductShared() ? $session->getSocialProductShared() : array();
// remove product by parent share product
if (in_array($product_id, $SocialProductShared)) {
$quote = $session->getQuote();
$items = $quote->getAllVisibleItems();
foreach ($items as $item) {
$infoRequest = unserialize($item->getOptionByCode('info_buyRequest')->getValue());
if (isset($infoRequest['option'])) {
$option = unserialize($infoRequest['option']);
if ($option['shared_by']) {
$item_product_id = $item->getProduct()->getId();
if (in_array($item_product_id, $OriginSocialGiftIds) && $option['shared_by'] == $product_id) {
// remove out of quote
$quote->removeItem($item->getId())->save();
// update add list gift
$this->updateListGift($item_product_id, 'add');
}
}
}
}
$this->resetGiftSession();
// <=> $session->setSocialGiftStatus('note_share');
}
if (in_array($product_id, $OriginSocialGiftIds)) {
$this->updateListGift($product_id, 'add');
}
return;
}
示例12: addSubscriptionProductSubscriptionToQuote
/**
* Add the selected subscription product subscription to the quote item, if one is selected
*
* @event sales_quote_add_item
* @param Varien_Event_Observer $observer
* @return $this|void
*/
public function addSubscriptionProductSubscriptionToQuote(Varien_Event_Observer $observer)
{
/** @var Mage_Sales_Model_Quote_Item $quoteItem */
/** @noinspection PhpUndefinedMethodInspection */
$quoteItem = $observer->getQuoteItem();
/** @var Mage_Catalog_Model_Product $product */
$product = $quoteItem->getProduct();
$subscriptionId = $quoteItem->getBuyRequest()->getData('adyen_subscription');
if (!$subscriptionId) {
return $this;
}
$this->_loadProductSubscriptionData($product);
if (!$product->getData('adyen_subscription_data')) {
return $this;
}
/** @var Adyen_Subscription_Model_Resource_Product_Subscription_Collection $subscriptionCollection */
$subscriptionCollection = $product->getData('adyen_subscription_data');
if ($subscriptionCollection->count() < 0) {
return $this;
}
/** @var Adyen_Subscription_Model_Product_Subscription $subscription */
$subscription = $subscriptionCollection->getItemById($subscriptionId);
$option = $quoteItem->getOptionByCode('additional_options');
if ($subscription) {
$subscriptionOption = ['label' => Mage::helper('adyen_subscription')->__('Subscription'), 'code' => 'adyen_subscription', 'option_value' => $subscriptionId, 'value' => $subscription->getFrontendLabel(), 'print_value' => $subscription->getFrontendLabel()];
} else {
$subscriptionOption = ['label' => Mage::helper('adyen_subscription')->__('Subscription'), 'code' => 'adyen_subscription', 'option_value' => 'none', 'value' => Mage::helper('adyen_subscription')->__('No subscription'), 'print_value' => Mage::helper('adyen_subscription')->__('No subscription')];
}
if ($option == null) {
$quoteItemOption = Mage::getModel('sales/quote_item_option')->setData(['code' => 'additional_options', 'product_id' => $quoteItem->getProductId(), 'value' => serialize([$subscriptionOption])]);
$quoteItem->addOption($quoteItemOption);
} else {
$additional = unserialize($option->getValue());
$additional['adyen_subscription'] = $subscriptionOption;
$option->setValue(serialize($additional));
}
}
示例13: modifyPrice
public function modifyPrice(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig('deals/general/enabled')) {
$item = $observer->getQuoteItem();
$item = $item->getParentItem() ? $item->getParentItem() : $item;
$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;
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
}
}
}
}
}
示例14: disableRemoveQuoteItem
public function disableRemoveQuoteItem(Varien_Event_Observer $observer)
{
if (Mage::helper('qquoteadv')->isActiveConfirmMode()) {
$product = $observer->getQuoteItem();
$product->isDeleted(false);
$message = Mage::helper('qquoteadv')->__('Action is blocked in quote confirmation mode');
Mage::getSingleton('checkout/session')->addError($message);
}
return $this;
}
示例15: productCart
/**
* productCart Cart product add observer , used for managing the seller assign product stock
* @param Object $obs Containes the cart data
* @var Object $db Data base connection object
* @var Object $cart_data Containes cart items
* @var Object $item current product added Cart item object
* @var Object $info Conatines the updated cart item information
* @var Int $current_qty Updated item quote quantity
* @var Int $productId Updated item product id
* @var Int $mpassignproductId Updated item assign product id
* @var Array $temp Containes item options [description]
* @var Object $productDetail Assign product model object
* @var Float $price Assign product price
* @var Float $avlqty Assign product available qty
* @var Int $diff Difference between available qty and cart item quote quantity
* @var Int $seller Assign product vendot id
* @var Array $options Configurable assign product associated products option
* @var Int $adminAvlQty Admin product available qty
*/
public function productCart(Varien_Event_Observer $obs)
{
$cart_data = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();
$item = $obs->getQuoteItem();
$item = $item->getParentItem() ? $item->getParentItem() : $item;
$db = Mage::getSingleton('core/resource')->getConnection('core_read');
$productId = $item->getProductId();
foreach ($cart_data as $cart) {
if ($cart->getProductId() == $productId) {
$quantity = $cart->getQty();
}
}
$productId = $item->getProductId();
$mpassignproductId = 0;
foreach ($item->getOptions() as $option) {
$temp = unserialize($option['value']);
if (isset($temp['mpassignproduct_id'])) {
$mpassignproductId = $temp['mpassignproduct_id'];
}
}
if ($mpassignproductId) {
$productDetail = Mage::getModel('mpassignproduct/mpassignproduct')->load($mpassignproductId);
if ($productDetail->getProductType() != "configurable") {
$price = $productDetail->getPrice();
$avlqty = $productDetail->getQty();
$seller = $productDetail->getSellerId();
$diff = $avlqty - $quantity;
if ($diff > 0) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
} else {
if ($diff <= 0) {
if ($quantity == $avlqty) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
$item->setQty($avlqty);
} elseif ($quantity > $avlqty) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
$item->setQty($avlqty);
Mage::getSingleton('core/session')->addNotice('Number of quantity not available.');
}
}
}
} else {
$options = unserialize($productDetail->getConfigOptions());
$price = $options['products'][$obs->getQuoteItem()->getProductId()]['price'];
$avlqty = $options['products'][$obs->getQuoteItem()->getProductId()]['qty'];
$seller = $productDetail->getSellerId();
$diff = $avlqty - $quantity;
if ($diff > 0) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
} else {
if ($diff <= 0) {
if ($quantity == $avlqty) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
$item->setQty($avlqty);
} elseif ($quantity > $avlqty) {
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
$item->setQty($avlqty);
Mage::getSingleton('core/session')->addNotice('Number of quantity not available.');
}
}
}
}
} else {
$id = Mage::getModel('catalog/product')->getIdBySku($item->getSku());
$_product = Mage::getModel('catalog/product')->load($productId);
if ($_product->getTypeId() != 'configurable') {
$item->setCustomPrice($item->getProduct()->getPrice());
$item->setOriginalCustomPrice($item->getProduct()->getPrice());
$adminAvlQty = Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($productId);
//.........这里部分代码省略.........