2

I am creating a custom VirtueMart order item export. Some products have a custom field of type "Cart Variant". In this specific case, customers can select "yes" or "no" from a list when they put the product in the basket. I need to include the customer entered value in my order item export.

It seems custom field values are not stored as one might expect. The only thing I have been able to find, is a piece of json wrapped HTML in column product_attribute of table #__virtuemart_order_items. I could preg_match the value out of there, but that's rather crude and quite unreliable. Unfortunately I haven't been able to find the actual data as a plain value anywhere.

Can anybody tell me if I am missing something?

Artemix
  • 2,113
  • 2
  • 23
  • 34

1 Answers1

0

The Product attribute you can find in the #__virtuemart_order_items

The field product_attribute contain exact value and the title of the custom field.

eg:

{"2558":" <span class=\"costumTitle\">Gift Wrap<\/span><span class=\"costumValue\" >Yes<\/span>"}

this is the value of the field in the product_attribute coloumn (json_encoded)

The class customTitle class span is the field label. = Gift Wrap. and the customValue class span contain value. = Yes

You can just get this value like

First html tags with span should convert to corresponding symbols. here like

&lt;span class=&quot;costumTitle&quot;&gt;Gift Wrap&lt;/span&gt;&lt;span class=&quot;costumValue&quot; &gt;Yes&lt;/span&gt;

Then simply json_decode($value,true); The return array will get your content properly

eg:

$str = '{"2558":"&lt;span class=&quot;costumTitle&quot;&gt;Gift Wrap&lt;/span&gt;&lt;span class=&quot;costumValue&quot; &gt;Yes&lt;/span&gt;"}';
$ar = json_decode($str,true);
print_r($ar);

output like:

Array ( [2558] => <span class="costumTitle">Gift Wrap</span><span class="costumValue" >Yes</span> ) .

Hope it will Help..

Jobin
  • 8,238
  • 1
  • 33
  • 52