Just another WordPress.com weblog


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


Comments on: "How to add wholesale price in shopping cart" (3)

  1. Hello Bijal,

    Thanks for sharing your knowledge. This article is very easy to understand any guys, and very useful to customization price in the shopping cart.

    Manish B

  2. Hi Bijal,

    I am trying to modify the shopping cart to have a total that would calculate totals = qty x weight x price. Have you done something like that, or could you point me to which files need to be modified? At the moment I cant locate where the totals is being calculated.



    • Hello Ben,

      If you wants to change total like qty X weight X price than you can change in collect() function in file:/yourproject/app/code/local/Mage/Sales/Model/Quote/Address/Total/Subtotal.php, like we did in the post.

      Bijal Bhavsar 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: