Just another WordPress.com weblog

Posts tagged ‘shopping cart’

How to add wholesale price in shopping cart


If you want to add wholesale price and you want to do some calculations on total price to change subtotal, than follow below steps:

Step1: Create one attribute `wholesale_price` .

Step2: Add getWholesalePrice() function defined bellow in


public function getWholesalePrice($pID)
$_product = Mage::getModel(‘catalog/product’);
return   $_product->getResource()->getAttribute(‘wholesale_price’)

Step3:  Open file yourproject/app/code/local/Mage/Sales/Model/Quote/item.php

Add below line in   function setProduct  ->setWholesalePrice(Mage::getModel(‘checkout/cart’)


after ->setCost($product->getCost()) statement in function

Step4: To change subtotal open below path file


public function collect(Mage_Sales_Model_Quote_Address $address)
* Reset subtotal information

* Process address items
$items = $address->getAllItems();
/*******Start:: Changes  for wholesale price calculation********/
$isWholesalePrice = false;
$finaltotal = ”;
/*******END:: Changes  for wholesale price calculation********/
foreach ($items as $item) {
if (!$this->_initItem($address, $item) || $item->getQty()<=0) {
$this->_removeItem($address, $item);
/******START:: Changes  for wholesale price calculation*******/
$_totWholesalePrice = $item->getWholesalePrice() * $item->getQty();
$_totPrice = $item->getPrice() * $item->getQty();
if($_totWholesalePrice >= 500 || $_totPrice >= 1000)
$isWholesalePrice = true;
$finaltotal += $_totWholesalePrice;
/*******END::Changes  for wholesale price calculation*******/
/******START::Changes  for wholesale price calculation******/
/******END:: Changes  for wholesale price calculation********/

/*** Initialize grand totals***/



return $this;

Explaination of above function:: In above function we changed calculation of subtotal, here condition is if total wholesale price(wholesale price *  Qty) of any product is more than 500 or total price(Sale price * Qty)  is more than 1000 than subtotal is calculated on wholesale price.

Above four step will help u to change subtotal and grand total according to subtotal for only one page checkout. To reflect the above calculation to multishipping than follow step5also.

Step5: Open file /yourproject/app/code/local/Mage/Sales/Model/Quote/Address/Item.php

Add below line in   function importQuoteItem


after ->setPrice($quoteItem->getPrice()) statement.

If this post is helpful to you than please do write feedback.


-Bijal Bhavsar