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; }
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); } }
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; } }
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(); } } } }
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); } }
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); }
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); } }
/** * 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()); } }
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); } }
/** * 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; }
/** * 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; }
/** * 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)); } }
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); } } } } }
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; }
/** * 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); } else { $item->setCustomPrice($item->getProduct()->getFinalPrice()); $item->setOriginalCustomPrice($item->getProduct()->getFinalPrice()); $item->getProduct()->setIsSuperMode(true); $adminAvlQty = Mage::getModel('mpassignproduct/mpassignproduct')->getConfigAssignProDetails($productId, $id); } if ($quantity > $adminAvlQty['sellerqty'] && count($adminAvlQty)) { if ($adminAvlQty['sellerqty'] == 0) { Mage::throwException("Number of quantity not available."); } else { $item->setQty($adminAvlQty['sellerqty']); Mage::getSingleton('core/session')->addNotice('Number of quantity not available.'); } } } }
public function setCustomAttribute(Varien_Event_Observer $observer) { $item = $observer->getQuoteItem(); $product = $observer->getProduct(); $item->setCustomAttribute($product->getCustomAttribute()); }
public function applyQuotePrice(Varien_Event_Observer $observer) { $item = $observer->getQuoteItem(); if (Mage::getSingleton('core/session')->getIsQuoteAddedToCart()) { if (Mage::getSingleton('customer/session')->getQuoteCreatedThroughUpload()) { $quote_id = Mage::getSingleton('customer/session')->getQuoteCreatedThroughUpload(); } else { $quote_id = Mage::getSingleton('core/session')->getCurrentQuote(); } $model = Mage::getModel("quote/quote"); $existing_quote_record = $model->load($quote_id); $quote_details = $existing_quote_record->getData(); $quote_products = explode(',', $quote_details['quote_product_ids']); $quote_product_qty = array_count_values($quote_products); $aud_prices = explode(',', $quote_details['quote_product_prices_aud']); $nzd_prices = explode(',', $quote_details['quote_product_prices_nzd']); $quote_product_price_aud = array_combine($quote_products, $aud_prices); $quote_product_price_nzd = array_combine($quote_products, $nzd_prices); // $quoteDiscount = Mage::getSingleton('core/session')->getQuoteDiscount(); $quoteDiscount = $quote_details['discount_value']; /* @var $item Mage_Sales_Model_Quote_Item */ $item = $observer->getQuoteItem(); $productid = $item->getProduct()->getId(); $product1 = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productid); $attribTxt = strtolower($product1->getAttributeText('product_type')); if ($item->getParentItem()) { $item = $item->getParentItem(); } $current_currency_code = Mage::app()->getStore()->getCurrentCurrencyCode(); if (sizeof(array_filter($aud_prices)) != 0) { // if($quoteDiscount && Mage::getSingleton('customer/session')->getQuoteCreatedThroughUpload()){ // $quoteTotalAmount = Mage::getSingleton('core/session')->getQuoteAmount(); // $quoteTotalAmount = $quoteTotalAmount+($quoteDiscount*-1); // $itemprice_aud = $quote_product_price_aud[$productid]*$quote_product_qty[$productid]; // $quoteDiscount = $quoteDiscount*-1; // //// Product unit price = product unit price - (product unit price / Quote sub-Total ) * Total Discount // $itemPriceAfterDiscountInAud = $itemprice_aud - ($itemprice_aud/$quoteTotalAmount) * $quoteDiscount; //// echo '<pre>'; //// echo '$itemprice_aud:'.$itemprice_aud.'<br/>'; //// echo '$quoteTotalAmount:'.$quoteTotalAmount.'<br/>'; //// echo '$quoteDiscount:'.$quoteDiscount.'<br/>'; //// print_r('$itemPriceAfterDiscountInAud:'.$itemPriceAfterDiscountInAud); //// exit; // $itemprice_aud = $itemPriceAfterDiscountInAud; // $itemprice_nzd = $quote_product_price_nzd[$productid]*$quote_product_qty[$productid]; $itemPriceAfterDiscountInNzd = $itemprice_nzd - ($itemprice_nzd/$quoteTotalAmount) * $quoteDiscount; // $itemprice_nzd = $itemPriceAfterDiscountInNzd; // }else{ $qtys = explode(',', $quote_details['quote_product_qtys']); $amount = 0; if ($current_currency_code == 'NZD') { $amounts = array_filter(explode(',', $quote_details['quote_product_prices_nzd'])); $currency = "NZ\$ "; } else { $amounts = array_filter(explode(',', $quote_details['quote_product_prices_aud'])); $currency = "AU\$ "; } for ($i = 0; $i < count($qtys); $i++) { $amount += $qtys[$i] * $amounts[$i]; } $quoteTotalAmount = $amount; $itemprice_aud = $quote_product_price_aud[$productid] * $quote_product_qty[$productid]; $quoteDiscount = $quoteDiscount * -1; // Product unit price = product unit price - (product unit price / Quote sub-Total ) * Total Discount $itemPriceAfterDiscountInAud = $itemprice_aud - $itemprice_aud / $quoteTotalAmount * $quoteDiscount; $itemprice_aud = $itemPriceAfterDiscountInAud; $itemprice_nzd = $quote_product_price_nzd[$productid] * $quote_product_qty[$productid]; $itemPriceAfterDiscountInNzd = $itemprice_nzd - $itemprice_nzd / $quoteTotalAmount * $quoteDiscount; $itemprice_nzd = $itemPriceAfterDiscountInNzd; // } } else { $itemprice_aud = $product1->getFinalPrice() * 1; $itemprice_nzd = $this->priceinNzd($itemprice_aud); } if ($current_currency_code == 'NZD') { $item->setCustomPrice($itemprice_nzd); $item->setOriginalCustomPrice($itemprice_nzd); } else { $item->setCustomPrice($itemprice_aud); $item->setOriginalCustomPrice($itemprice_aud); } $item->getProduct()->setIsSuperMode(true); if ($attribTxt == 'software product' or $attribTxt == 'maintenance product') { $item->getCustomPrice(); } } else { $prodId = $item->getProduct()->getId(); $storeId = Mage::app()->getStore()->getStoreId(); $product1 = Mage::getModel('catalog/product')->setStoreId($storeId)->load($prodId); $attribTxt = $product1->getAttributeText('product_type'); if (strtolower($attribTxt) == 'maintenance product') { $items = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems(); foreach ($items as $item) { $prod = $item->getProduct(); $productId = $prod->getId(); $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId); $attribTxt1 = $product->getAttributeText('product_type'); // if(strtolower($attribTxt1)=='maintenance product'){ // Mage::getSingleton('checkout/session')->addError(Mage::helper('checkout')->__('Upgrade Assurance Product already added to the cart')); // header("Location: " . $product1->getProductUrl()); // die(); // } } } else { $this->getCustomPrice(); } } // if(!Mage::getSingleton('customer/session')->getQuoteCreatedThroughUpload()){ // // $this->getCustomPparice(); // } }
public function checkoutcart(Varien_Event_Observer $observer) { $customerid = Mage::getSingleton('customer/session')->getCustomerId(); $event = $observer->getQuoteItem(); $request = $event->getRequest(); $biddings = Mage::getResourceModel('wkbidding/wkbidding_collection'); $biddings->addFieldToFilter('productid', $event->getProduct()->getId()); $biddings->addFieldToFilter('status', 1); $mpp = Mage::getModel('wkbidding/biddingproducts')->getCollection(); $mpp->addFieldToFilter('productid', $event->getProduct()->getId()); $mpp->setOrder('id'); foreach ($mpp as $ky) { $bidid = $ky['id']; break; } foreach ($biddings as $bidding) { if ($bidding['userid'] == $customerid && $bidding['shop'] == 0 && $bidid == $bidding['bid_id']) { $event->setOriginalCustomPrice($bidding['biddingprice']); $event->setCustomPrice($bidding['biddingprice']); } } }
public function modifyPrice(Varien_Event_Observer $observer) { $noPay = Mage::getStoreConfig(self::NO_PAY); $pay = Mage::getStoreConfig(self::PAY); $private = Mage::getStoreConfig(self::PRI); $payMethod = Mage::getSingleton("core/session")->getPerscriptionCheck(); $item = $observer->getQuoteItem(); $price = $item->getProduct()->getData('price'); $item = $item->getParentItem() ? $item->getParentItem() : $item; // check is_prescription_product if ($item->getProduct()->getData('is_prescription_product') == '1') { // amend price so that VAT is taken into account if ($payMethod === 'no_pay') { $exemption = Mage::getSingleton("core/session")->getPrescriptionExemptionCheck(); if ($exemption > 0) { $item->getProduct()->setIsSuperMode(true); $item->setCustomPrice($noPay); $item->setOriginalCustomPrice($noPay); } } if ($payMethod === 'pay') { $item->getProduct()->setIsSuperMode(true); $item->setCustomPrice($pay); $item->setOriginalCustomPrice($pay); } if ($payMethod === 'private') { $item->getProduct()->setIsSuperMode(true); $item->setCustomPrice($private); $item->setOriginalCustomPrice($private); } } }
public function catchAddToCart(Varien_Event_Observer $observer) { if ($this->_getHelper()->isEnabled() && Mage::getSingleton('customer/session')->isLoggedIn()) { $data = $this->_getRequestDataObject(); $data->setEmail(Mage::getSingleton('customer/session')->getCustomer()->getEmail()); $data->setSku($observer->getProduct()->getSku()); $data->setQty($observer->getQuoteItem()->getQty()); $data->setPrice($observer->getProduct()->getPrice()); $this->_getApi()->addLeadConversion(self::LEAD_PRODUCTADDEDTOCART, $data); } }
public function zipAddToCart(Varien_Event_Observer $observer) { $session = Mage::getSingleton("core/session", array("name" => "frontend")); $zip = $session->getData("zip"); $item = $observer->getQuoteItem(); $item->setZipcode($zip); }
/** * change product price for mtm products (made to measure) * * @param Varien_Event_Observer $observer */ public function mtmProductModifyAddToCart(Varien_Event_Observer $observer) { $item = $observer->getQuoteItem(); $this->_mtmProductModifyPrice($item); }