Author Topic: Removing color from product custom field removes it from order itself  (Read 796 times)

Huubs

  • Jr. Member
  • **
  • Posts: 147
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4047
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Removing color from product custom field removes it from order itself
« Reply #1 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.

Huubs

  • Jr. Member
  • **
  • Posts: 147
Re: Removing color from product custom field removes it from order itself
« Reply #2 on: October 21, 2019, 12:01:24 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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3016
  • VirtueMart Version: 3.6.3
Re: Removing color from product custom field removes it from order itself
« Reply #3 on: October 21, 2019, 12:54:41 pm »
Look at the PDF
regards
A

Joomla 3.9.12
php 7.2

Huubs

  • Jr. Member
  • **
  • Posts: 147
Re: Removing color from product custom field removes it from order itself
« Reply #4 on: October 24, 2019, 14:30:30 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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3016
  • VirtueMart Version: 3.6.3
Re: Removing color from product custom field removes it from order itself
« Reply #5 on: October 25, 2019, 12:57:01 pm »
I see your problem - especially when customfields may be changed
regards
A

Joomla 3.9.12
php 7.2

Huubs

  • Jr. Member
  • **
  • Posts: 147
Re: Removing color from product custom field removes it from order itself
« Reply #6 on: November 01, 2019, 12:53: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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3016
  • VirtueMart Version: 3.6.3
Re: Removing color from product custom field removes it from order itself
« Reply #7 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
regards
A

Joomla 3.9.12
php 7.2

Huubs

  • Jr. Member
  • **
  • Posts: 147
Re: Removing color from product custom field removes it from order itself
« Reply #8 on: November 01, 2019, 13:44:20 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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3016
  • VirtueMart Version: 3.6.3
Re: Removing color from product custom field removes it from order itself
« Reply #9 on: November 01, 2019, 15:56:34 pm »
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.9.12
php 7.2

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9973
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Removing color from product custom field removes it from order itself
« Reply #10 on: November 01, 2019, 16:08:23 pm »
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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3016
  • VirtueMart Version: 3.6.3
Re: Removing color from product custom field removes it from order itself
« Reply #11 on: November 01, 2019, 18:22:43 pm »
I did not think it was easy - after looking at the order item database entries and the plugin coding  :)
regards
A

Joomla 3.9.12
php 7.2

Huubs

  • Jr. Member
  • **
  • Posts: 147
Re: Removing color from product custom field removes it from order itself
« Reply #12 on: November 07, 2019, 14:44:52 pm »
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.