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

Apply cart condition once on cart item regardless of its quantity #342

Open
HuyPham55 opened this issue Jul 12, 2022 · 4 comments
Open

Apply cart condition once on cart item regardless of its quantity #342

HuyPham55 opened this issue Jul 12, 2022 · 4 comments

Comments

@HuyPham55
Copy link

First I'm not sure if this is the right place for discussions/questions
Second I want to apply an item condition (Per-Item Bases) only one only one time for a row, is this possible?

For example, I have a row with quantity = 3 and price = 200. However I want to apply an discount (-50) for only the first, the 2 following will have original price, so the subtotal of that row is 150+200+200 = 550.

I've read the document thoroughly and tried my luck with addItemCondition. But instead it applies to all items in that row so the subtoal ended up being 150*3 = 450.

How I am supposed to achieve this?

@Blum
Copy link

Blum commented Jul 12, 2022

Hmm looks like "Condition on Per-Item Bases" is just for that.. it is right there in the Readme. You can apply it on add, or later:

Add condition to existing Item on the cart: Cart::addItemCondition($productId, $itemCondition)

Works fine for me. Maybe check if you've given the right $productId

Cheers

@HuyPham55
Copy link
Author

Not sure if you've read my question entirely. It's about the quantity of the condition, not how to add condition to a cart item

@Blum
Copy link

Blum commented Jul 19, 2022

If you want to achieve this, you should somehow save the second and the third product with different ID, so they won't get under the condition like the first one.
But I don't think this could happen for the products under the same ID in the cart.

I would make it with some checks on adding, if the product exists in the cart, to save it with some prefix (or suffix) on the ID. And to apply this condition only on the products that have no suffix. Something like that.

Cheers

@HuyPham55
Copy link
Author

If you want to achieve this, you should somehow save the second and the third product with different ID, so they won't get under the condition like the first one. But I don't think this could happen for the products under the same ID in the cart.

I would make it with some checks on adding, if the product exists in the cart, to save it with some prefix (or suffix) on the ID. And to apply this condition only on the products that have no suffix. Something like that.

Cheers

That requires extra work when it comes to display the shopping cart items (adding/subtracting product quantity to be specific) since you are creating a whole new row, while in fact, it's the same product. I just wondering if there is any native way or integrated configuration for that. Thank you anyway

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

2 participants