I update the product price (.price-box) on the product page via some custom JS component. When putting the product into cart it still has the old value from before the update.

How can I put the product into cart with the new price without actually saving the product with the new price but keeping it in cart and checkout?

  • Dava, Did you write a function? Commented May 15, 2018 at 17:42

1 Answer 1


Assuming this is Magento 1.x if not let me know and I'll provide M2 version

You need to do this by hooking into the add to cart action using the observer and do something similar to this

private function replaxePrice($product_id,$newPrice){

$quote = Mage::getSingleton('checkout/session')->getQuote(); 

foreach ($quote->getAllVisibleItems() as $item) {
if($item->getProduct()->getId() != $product_id) continue; 

if ($newPrice > 0) { 


Sorry about poor formatting. Only certain thing I can do on mobile

Why reinvent the wheel, I has someone ask me this recently and I sent them this reference

Updated for M2


Hope this resolved your issues

  • This looks like some M1 snippet, I am on M2 ;-) Furthermore how should I get the price from my Frontend JS component? Doesn't sound like a viable solution to be honest
    – codedge
    Commented Jun 21, 2017 at 21:54
  • Ahh.. sorry - I disnt read your updated version.. yes M2
    – codedge
    Commented Jun 21, 2017 at 21:55
  • Same principle really you just need to hook into the add to cart event and update price similar to M1 Commented Jun 21, 2017 at 21:57
  • But the new price is calculated only in JS. How shall I pass it to the event?
    – codedge
    Commented Jun 21, 2017 at 21:58
  • Iv updated my post that should point u in right direction Commented Jun 21, 2017 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.