Can anyone tell me in magento, when we click Add to Cart button in product detail page, where and how is Product Price and Qty input multiplied and updated in shopping cart page Subtotal column. I want to customize the action for my custom pricing module.
2 Answers
The subtotal logic on the cart page is implemented in the below template file.
app/design/frontend/rwd/default/template/checkout/cart/item/default.phtml
Override this file into your local and modify it as per your requirement.
-
thank you for the reply.. can u pls tell me how does the subtotal in cart page logic goes in while clicking Add to Cart in PDP (product price * qty) Jun 16, 2015 at 10:51
-
-
Guess that
You want to change cart item unit price.I
So in this case,you can use magento event/observer
.
Basically there are two events,by which you can change the cart price of that products:
checkout_cart_product_add_after
checkout_cart_update_items_after
checkout_cart_product_update_after
This 3 event is need because of:
Event1:checkout_cart_product_add_after
This event is fire when first time a product is cart for current session
of current input values from frontend
Event2:checkout_cart_product_update_after
This event is fire when a current exiting cart item
edited from edit link of cart item.
Event3:checkout_cart_update_items_after
This event is fire whenever cart items update from cart page.
As per as magento system, a cart item price
change using setter
functions setCustomPrice(), setOriginalCustomPrice
of cart item Object.
Just like:
$EachCartitem->setCustomPrice($price);
$EachCartitem->setOriginalCustomPrice($price);
// Enable super mode on the product.
$EachCartitem->getProduct()->setIsSuperMode(true);
If you can cart each unit price then automatically change subtotal
An example: Custom options operations
-
Thank u Amit. I have set the new price and it's updated in quote table using event/obs. The problem is, I'm changing the Prod Price displayed in my pdp using ajax when my customer enters a number. Along with tat I'm using several parameters and calculating the custom prod price. It's updated in the same div where magento displays the unit price frm backend. So when I add to cart, the unit price in cart is getting updated as my custom price. I wanna stop it. Also I need to prevent the prod price * qty functionality. Jun 16, 2015 at 12:59
customize the action for my custom pricing module.