News:

Support the VirtueMart project and become a member

Main Menu

Removing color from product custom field removes it from order itself

Started by Kuubs, October 19, 2019, 09:50:38 AM

Previous topic - Next topic

Kuubs

Hello,


I have a weird bug. When I remove the custom field color from my product, the already ordered products also the color gets removed.

So for example. I have Product One with custom field Color = Black, Red and green. These are all strings and all seperate instances. When I remove the color black from that product. Every Product One that is ordered is the color black removed. How is this possible?]

EDIT: So I checked the database and this is what is set at the product_attribute column:

{
    "3": "570",
    "15": "573",
    "17": "624"
}

Is this in reference to? Because if that is so, how can I get it back. I tried readding the field, but it won't display. Is it because I removed the ID from the color from the product and now it doesn't know the reference? Seems like a really dumb way of programming it? Why not just use the name and the value of the custom field?

EDIT2: I think in the database jos_virtuemart_product_customfields I need to change this. But why is it removed in the first place? And how can I get it back? I'm fine with adding a row to the database so it works again but I cannot understand why this would happen in the first place. Seems really dumb to have it work like this.

EDIT3: I got it working again by manually adding a row with the correct id's, and disabling the custom field so it doesn't show up in the productdetails page. But I'm kinda confused why this happened. Can someone explain to me why this happens?

Studio 42

The problem is that the render is dynamic in the order, this mean that if you remove the field after in the product, the order dont have any reference anymore and cannot display it.

Kuubs

Quote from: Studio 42 on October 19, 2019, 13:04:52 PM
The problem is that the render is dynamic in the order, this mean that if you remove the field after in the product, the order dont have any reference anymore and cannot display it.

But that doesn't make any sense at all. Why remove the whole row? Instead of just disabling it? THat seems like a major oversight because existing orders should never lose any custom fields, unless you specify it. That is a major oversight. This is really detrimental to the webshop because suddenly I don't have any color set on the ordered product.

AH

Regards
A

Joomla 3.10.11
php 8.0

Kuubs

Quote from: AH on October 21, 2019, 12:54:41 PM
Look at the PDF

That's an option, but my clients use the order screen in VM self to check the orders, and also use a XML export function on the website to get the orders in XML format for better administration.

AH

I see your problem - especially when customfields may be changed
Regards
A

Joomla 3.10.11
php 8.0

Kuubs

Quote from: AH on October 25, 2019, 12:57:01 PM
I see your problem - especially when customfields may be changed

So is there a solution for this? Or do I need to workaround this issue at the moment? (I can for example use the database to add the disabled check in the database)

AH

There is no solution

Custom fields are rendered every time the order is viewed using the stored values but they are "run" through the plugin which attempts to re-render them
Regards
A

Joomla 3.10.11
php 8.0

Kuubs

Quote from: AH on November 01, 2019, 13:24:17 PM
There is no solution

Custom fields are rendered every time the order is viewed using the stored values but they are "run" through the plugin which attempts to re-render them

Great, so that seems like a major design flaw. Good to know.

AH

You can always attempt to redesign it yourself and provide the solution back to the core for review

Or if you have a gold membership - you could ask for a modification to be considered going forward

https://extensions.virtuemart.net/support/virtuemart-supporter-membership-gold-detailr this to be reviewed
Regards
A

Joomla 3.10.11
php 8.0

Milbo

Hmmm,

not so easy. Sometims you want to change a product also for an existing order (for example, update the provided download).

The simple customfield string also writes the values plain into the db, imho
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

I did not think it was easy - after looking at the order item database entries and the plugin coding  :)
Regards
A

Joomla 3.10.11
php 8.0

Kuubs

I found a workaround. Maybe this is something that could be implemented because, well, it's already there.

If I make a child product I have 2 extra options and the custom field, 2 checkboxes, d checkbox and o checkbox, meaning the disable checkbox and the override checkbox. When I use the disable checkmark, the color disappears from the productdetails page, but is still there in the order itself. Unfortunately this is not default behaviour, the only way for me (as far as I know) to get these checkboxes is to use child variants, or, go into the database and set a 1 at the override column. Now the checkboxes appear and I can disable the custom field.

Is it possible to add these checkboxes default? Because that would be a simple yet effective solution.

Milbo

So when you remove a customfield, which was used in an order, it should issue an warning and set it to a kind of "hidden". Hmmm.

another idea is to store the data somewhere. I have an idea.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Kuubs

Quote from: Milbo on December 20, 2019, 09:31:41 AM
So when you remove a customfield, which was used in an order, it should issue an warning and set it to a kind of "hidden". Hmmm.

another idea is to store the data somewhere. I have an idea.

Yeah exactly. That would be great. Because I think this can happen to other users as well, because it's not really apparent that when you delete the custom field it also deletes it in the order, which could be detrimental (at least in my case). Luckily I have some sort of workaround now, which is a hassle to do, but at least it works. But it could be implemented a more user friendly way ofcourse.