-
Notifications
You must be signed in to change notification settings - Fork 34
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
After adding the bundle, I am not able to add products with a customer option to the cart #131
Comments
Thanks for reporting the problem. This is indeed an issue that has been introduced by a more recent version of Sylius. What's the problemWell the problem is that the Why do we need to change the
|
@mamazu, thanks for the fast response and the in-depth details. That's more or less what I also thought. Also, your conclusion is the same that I had yesterday: The logic needs to compare each and every customer option value. For my very specific use case, I can easily rely on the default Sylius logic. Let me see if I can find some time in the next weeks to come up with a PR. |
This is a bit more challenging than expected ;) The core issue - as I see it now - is that the main logic is executed in the PostEvent hook, which is too late to have all the needed data available in the equals() method to decide which items are equal. |
What exactly do you mean. Does the order item not yet have the customer option values the customer has entered? |
I tried this plugin with sylius 1.12 and i got |
Correct, at least that is my current observation. While debugging I was missing the information for the product that is added to the cart. Before your logic is running in the PostEvent several equals() calls are happing that miss this information. I tried to convert the PostEvent into a PreEvent but for some reason that did not fire correctly. Need to dig a bit deeper, I think. |
@mamazu I am slowly making progress. My initial plan of using the PreAdd event was not successful. The event gets triggered but also somehow too late. So I changed my plan and implemented a custom One minor problem popped up: Doctrine complains about a "not configured to cascade persist operation". Not entirely sure why, it looks like the cascade persist configuration are in place. But maybe I am missing something. |
@mamazu good news! I managed to get a working prototype ready. I'll convert that into a PR and then you can have a look if it makes sense. Will take a few more days since I'll be traveling next week. |
@t-n-y I don't think your issue is similar to mine. At least the error looks different. |
@shochdoerfer Ok, i ll test with your pr when it s ready and i ll see. thanks for the answer |
@shochdoerfer i tried your fork, but when i install it, i got following error : |
@t-n-y it's enough to replace |
Thx, do you mean on the fork or the last release ? |
Ok, I think i figured this out although it took a bit more effort to make this work. I realize it can be done better but it works.
I made something like this:
services.yaml
App\Factory\OrderItemOptionFactory.php
|
May bad, I completely lost track of this issue. Will have some time in the next weeks to optimize/finish the PR I started a while ago. |
@shochdoerfer did you had time to look at that issue ? |
@t-n-y a few minor things to fix plus getting the tests back in shape. Technically, the code in my branch should work now if you need a solution quickly. |
Awesome, thank you |
I installed the bundle as outlined in the Readme file in my Sylius 1.12 instance. I've configured a required customer option of type text, added the customer option group, and assigned the customer option group to one product. The product itself is a simple product with no variants. Even adding variants did not change anything.
When trying to add the product to the cart (providing a proper input value for the customer option), Sylius fails with the following error:
At first, I thought it was an incompatibility with the Sylius version I am using. I debugged things in depth and found the problem to be the comparison in
OrderItemCustomerOptionCapableTrait::equals()
The check fails because the call$product->hasCustomerOptions()
is true and is returned negated.Am I missing some configuration?
The text was updated successfully, but these errors were encountered: