Cart icon indicating copy to clipboard operation
Cart copied to clipboard

If the amount of money differs depending on the color of the same product, how do you implement it?

Open bellsmarket opened this issue 6 years ago • 2 comments

In the example, the price is the same even if the color of the same product differs. But how can I implement it if I want to set a price by color?

bellsmarket avatar Dec 12 '18 13:12 bellsmarket

You add two products as in the following code:

`$cart->add('1', 1, [ 'price' => '5.99', 'color' => 'Green' ]);

$cart->add('2', 1, [ 'price' => '9.99', 'color' => 'Purple' ]);`

The two cart entries wont be mixed up.

However, I strongly recommend not saving the price here. The cart data could be modified by the user.

josxha avatar Jan 10 '19 14:01 josxha

its better to work with IDs here and do the calculation on the PHP Site not in the session or cookie.

1d0navan avatar Aug 14 '19 11:08 1d0navan