When a user buys 10 units of product B, the user wants 1 unit of Product A to be
automatically added to the cart. How can this requirement be fulfilled?
12 comments · newest first
FR
Francine
3 months ago
Option C seems right. It processes before adding to the cart.
LU
Luke
3 months ago
I prefer option D. It directly relates to adding items.
LA
Lavera
3 months ago
I think option B is the best choice. It prepares the cart before saving.
PA
Paz
4 months ago
Why would you need to add A only when buying 10 of B? Seems odd.
LE
Lezlie
4 months ago
I agree with B, makes the most sense for saving the cart.
RO
Rosio
4 months ago
Wait, can we really override those methods? Sounds tricky!
JO
Josphine
5 months ago
Nah, I’m pretty sure it’s D.
AA
Aaron
6 months ago
I think option B is the right choice.
CL
Clemencia
6 months ago
I’m leaning towards the preprocess method, but I can't recall exactly how it fits into the cart logic.
BA
Barrett
7 months ago
I feel like the AllowCheckout method wouldn't be the right choice here since it’s more about the checkout process, not adding items.
CR
Cristal
7 months ago
I remember practicing a similar question where we had to modify cart behavior, and I think the prepareForSave method was involved.
GR
Graciela
7 months ago
I think we might need to override the prepareToAdd method since it deals with adding items to the cart, but I'm not entirely sure.