coreshop / CoreShop

CoreShop - Pimcore enhanced eCommerce
http://www.coreshop.org
Other
276 stars 157 forks source link

[Coreshop2] Product price and update #197

Closed sriram246 closed 6 years ago

sriram246 commented 6 years ago

Hi Dominik, I have configured some products in the Admin. Is there a way to calculate the price automatically when i want to upate the cart in the frontend. For example

if I have one product A and if i increase the quantity from 1 to 2, Product B and increase the quantity from 1 to 2 it should update for each row automatically the total amount. If i increase Product A quantity from 1 to 2 and Product B quantity from 2 to 3 it must automatically update the quantity and calculate the total price for Product A and B and show the final price by combining Product A and Product B.

dpfaffenbauer commented 6 years ago

Hi Sriram246,

yeah sure. But you have to implement it yourself. The deal is: after changing the amount of a product in the cart, the cart gets recalculated. So you need to ping the server to update the cart and get the new price information. Best would be to make an ajax call and process the response in javascript and update the ui.

You can do that yourself by overwriting the CartController https://www.coreshop.org/docs/2.0.0/Development/Store_Front/Controllers.html

cheers

sriram246 commented 6 years ago

Hi Dominik, What I need to know is . if its possible for me to write one PHP class on my own where for each product only the Shipping Price(VersandKosten) is calculated for Prouct A , Product B and so on.

dpfaffenbauer commented 6 years ago

Thats done on saving the cart. So if you re-persist the cart by calling $cart->save(), an event listener is called which recalculates the cart. So you can then get the new shipping values from $cart->getShipping()

dpfaffenbauer commented 6 years ago

You are good now?

sriram246 commented 6 years ago

I will try that today and let you know.

dpfaffenbauer commented 6 years ago

Did that solve your problem?

dpfaffenbauer commented 6 years ago

I'll close this issue, If you have another questions regarding this, feel free to comment here again.