Programmatically add product to cart with price change

前端 未结 6 1335
孤街浪徒
孤街浪徒 2020-11-28 20:44

I want to add a product to cart programmatically. Also, I want to change the product price when added to cart.

Suppose, my product\'s price is $100. I wanted to cha

6条回答
  •  时光说笑
    2020-11-28 21:10

    Jonathan's answer is likely the best for most situations. But some customers might not like how shopping cart discounts are displayed in the cart. I recently did a project (with Magento 1.3.3) where the customer didn't like how the each line item still showed the full price as well as the subtotal, with a Discount line below the subtotal - he wanted to see the price of each item discounted, and the subtotal show the discounted price as well. He really didn't like having the Discount line after the Subtotal line.

    Anyway, if you find yourself in the same boat, one approach is to override the getCalculationPrice() and getBaseCalculationPrice() methods in Mage_Sales_Model_Quote_Address_Item and Mage_Sales_Model_Quote_Item. I know that it isn't always pretty to override, much better to use events, but in this case I couldn't get events to work seamlessly on both the frontend and backend. Not sure if this approach will work in Magento 1.4+.

提交回复
热议问题