Page 1 of 2
Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Thu Jun 01, 2023 4:10 am
by haydent
Hi, Ive been investigating the variant system and using it our website to create different models assigned to different option configs.
During this I noticed that, as the title suggests, when you add a variant to the cart, the oc system does a switch and adds the parent/master instead, but with the options specified in the variant.
Im not sure this is the best way, and may even be a mistake, as by adding the master into cart from that point on you loose all overridden fields that may be set in the variant, such as name, model etc. etc.
So in cart, checkout, order notifications, order history and product reordering that data is lost, in fact there is no record which variant product was "ordered" to begin with.
This seems to make no sense seems there is in fact a master_id field in order_product table, showing intention to store a variant product there, but it will never be used with the current method.
I even found out the add to cart system work perfectly fine for adding variants into the cart and checking out and re-ordering, if you comment out the code that switches the variant product id for its master id on add.
I created an issue on github to discuss this potential bug, among a bunch of other more obvious bugs related to variants, some breaking the system so bad its clear no-one is really using it, otherwise they would have been reported by now... and what do you know Daniel just says that is the way its meant to be, and that i shouldnt be bringing this (a potential bug) up here and closes the report... I ask again, why is there a master_id field in the order_product table ? (which seems to be in stark contrast to the "its perfect, go away" response from Daniel) Im not expecting a reply, but im just trying to help, I thought that was the spirit behind opensource, but i guess im just being idealistic

In fact ive been watching his behaviour in github to others just trying to help, and sadly its very rude and non-informative.
Anyway I made this post here to make record for anyone else wondering about the topic, to help this community and see what you think about it, maybe the behavior could be an admin option if its agreed that both ways have their uses ?
Here is my bug report which shows the one line that needs to be commented out, so the variant goes into cart instead of master.
https://github.com/opencart/opencart/issues/12338
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Wed Jul 05, 2023 11:47 pm
by straightlight
haydent wrote: ↑Thu Jun 01, 2023 4:10 am
Hi, Ive been investigating the variant system and using it our website to create different models assigned to different option configs.
During this I noticed that, as the title suggests, when you add a variant to the cart, the oc system does a switch and adds the parent/master instead, but with the options specified in the variant.
Im not sure this is the best way, and may even be a mistake, as by adding the master into cart from that point on you loose all overridden fields that may be set in the variant, such as name, model etc. etc.
So in cart, checkout, order notifications, order history and product reordering that data is lost, in fact there is no record which variant product was "ordered" to begin with.
This seems to make no sense seems there is in fact a master_id field in order_product table, showing intention to store a variant product there, but it will never be used with the current method.
I even found out the add to cart system work perfectly fine for adding variants into the cart and checking out and re-ordering, if you comment out the code that switches the variant product id for its master id on add.
I created an issue on github to discuss this potential bug, among a bunch of other more obvious bugs related to variants, some breaking the system so bad its clear no-one is really using it, otherwise they would have been reported by now... and what do you know Daniel just says that is the way its meant to be, and that i shouldnt be bringing this (a potential bug) up here and closes the report... I ask again, why is there a master_id field in the order_product table ? (which seems to be in stark contrast to the "its perfect, go away" response from Daniel) Im not expecting a reply, but im just trying to help, I thought that was the spirit behind opensource, but i guess im just being idealistic

In fact ive been watching his behaviour in github to others just trying to help, and sadly its very rude and non-informative.
Anyway I made this post here to make record for anyone else wondering about the topic, to help this community and see what you think about it, maybe the behavior could be an admin option if its agreed that both ways have their uses ?
Here is my bug report which shows the one line that needs to be commented out, so the variant goes into cart instead of master.
https://github.com/opencart/opencart/issues/12338
OC version. The addressed Github Opencart commit on the above has been closed already.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Thu Jul 06, 2023 4:47 am
by haydent
I believe variants are a OC4 thing, im running OC4.0.1.1 but will upgrade asap, but my suggestion applies right up to latest commit on master.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Fri Jul 14, 2023 1:36 am
by motofox
i never noticed this, im on 4.0.2.2 and when i add a variant to the cart, it also instead adds the master
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Fri Jul 14, 2023 1:40 am
by straightlight
motofox wrote: ↑Fri Jul 14, 2023 1:36 am
i never noticed this, im on 4.0.2.2 and when i add a variant to the cart, it also instead adds the master
Some features might of been changed by design. It's possible.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Fri Jul 14, 2023 5:53 am
by haydent
motofox wrote: ↑Fri Jul 14, 2023 1:36 am
i never noticed this, im on 4.0.2.2 and when i add a variant to the cart, it also instead adds the master
Are you sure? As I thought I checked latest github and it seemed like it had not changed since my version? I might have to check a 4022 install
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sat Jul 15, 2023 12:50 am
by motofox
im pretty sure unless im doing it wrong, added a variant and changed key data for the variant and saved along with switching on the extra switchs, variant shows but when added to shopping cart it shows the full master product. il test more
haydent wrote: ↑Fri Jul 14, 2023 5:53 am
motofox wrote: ↑Fri Jul 14, 2023 1:36 am
i never noticed this, im on 4.0.2.2 and when i add a variant to the cart, it also instead adds the master
Are you sure? As I thought I checked latest github and it seemed like it had not changed since my version? I might have to check a 4022 install
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sat Jul 15, 2023 6:18 am
by haydent
That's the problem, the default (in my opinion incorrect) behaviour is to add the master instead of the variant to the cart.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sat Jul 15, 2023 7:55 am
by straightlight
haydent wrote: ↑Sat Jul 15, 2023 6:18 am
That's the problem, the default (in my opinion incorrect) behaviour is to add the master instead of the variant to the cart.
Compare the codes with the master branch or replace the specific files to see if the issue has already been fixed.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sat Jul 15, 2023 9:54 am
by haydent
I have, master is the same as my version, it hasnt been fixed because Daniel doesnt think its a bug, yet there is proof that he's wrong. Please read my opening post.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sat Jul 15, 2023 7:27 pm
by straightlight
haydent wrote: ↑Sat Jul 15, 2023 9:54 am
I have, master is the same as my version, it hasnt been fixed because Daniel doesnt think its a bug, yet there is proof that he's wrong. Please read my opening post.
Then, produce a video to describe on how you believe the reported issue might be a bug.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sun Jul 16, 2023 5:37 am
by haydent

that is unnecessary and overkill, its simple 2 example reasons:
- there is a master_id field in the order_product table
- adding master looses all variant override details which then cant be used for checkout/reorder/order history/order notification the list goes on
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sun Jul 16, 2023 8:06 am
by straightlight
haydent wrote: ↑Sun Jul 16, 2023 5:37 am

that is unnecessary and overkill, its simple 2 example reasons:
- there is a master_id field in the order_product table
- adding master looses all variant override details which then cant be used for checkout/reorder/order history/order notification the list goes on
If you believe it to be unnecessary, then you are only trying to prove a point on a closed case.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sun Jul 16, 2023 5:21 pm
by haydent
Im just saying if you cant understand the issue by reading my opening post and asking any question here or making comments then this aint the topic for you...
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Sun Jul 16, 2023 8:32 pm
by straightlight
haydent wrote: ↑Sun Jul 16, 2023 5:21 pm
Im just saying if you cant understand the issue by reading my opening post and asking any question here or making comments then this aint the topic for you...
It ain't the topic for anyone since the commit you already addressed the issue about on Github, and now as a feedback, was closed for. Therefore, if you'd like to re-address the issue, please do so on Github.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Mon Jul 17, 2023 6:08 am
by haydent
I still dont think YOU understand my opening post and the reason for this thread.
There is NO commit you talk about.
There is a git issue I initially created before this thread to try and deal with it that way, but Daniel just disregarded me completely and closed it as he does commonly.
There is no point opening another issue on git, it will just be closed again with no response.
The problem has not been fixed.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Mon Jul 17, 2023 7:12 am
by straightlight
haydent wrote: ↑Mon Jul 17, 2023 6:08 am
I still dont think YOU understand my opening post and the reason for this thread.
There is NO commit you talk about.
There is a git issue I initially created before this thread to try and deal with it that way, but Daniel just disregarded me completely and closed it as he does commonly.
There is no point opening another issue on git, it will just be closed again with no response.
The problem has not been fixed.
That is the point I was mentioning on the above, so you did created an issue about it but has been closed already.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Mon Jul 17, 2023 9:55 am
by haydent
I still don't get why you saying just that adds anything to the discussion? You are just repeating what I have already stated in the first post...
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Mon Jul 17, 2023 4:24 pm
by MaxD
Suprisingly, this issue is fixed by just removing from
catalog/controller/checkout/cart.php this line:
Code: Select all
$product_id = $product_info['master_id'];
Also installing
opencart .mx extension fixes this bug and another known 4.0.2.2 bugs.
Re: Adding Variant to cart, adds the Master instead, but should it add the variant instead or optionally ??
Posted: Mon Jul 17, 2023 6:16 pm
by haydent
While it's nice to hear from someone else for a change, I actually mention the same fix already in the referenced issue in my opening post.
I wasn't really looking for solutions, I was making this thread to highlight Daniels inability to discuss what in my opinion is clearly a mistake / missed opportunity. And to see what others think about his decision to not change this.