Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bellsmarket opened this issue Dec 12, 2018 · 2 comments

Comments

@bellsmarket
Copy link

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?

@josxha
Copy link
Contributor

josxha commented Jan 10, 2019

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.

@1d0navan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants