Hello,
How can I get the product attributes in my order?
I need to send an API call, but using this: $product->product_attribute
I have this result: { "36": {"38474": { "custom_qvariant": "cappuccinocaffe ol\u00e8" } } }
How can I have this data?
Thanks a lot in advance!
http://php.net/manual/en/function.json-decode.php
then u have an array
Yes, I know.
But I'm asking because I'm not able to have the right result ;)
Thanks.
What you need exactly ?
Because if you need Html display, you need to get the product and use VirtueMartCustomFieldRenderer function or copy the code you need
I need to have the value of each custom field.
Thanks.
the code should be
if(!empty($product->product_attribute)) {
$json = json_encode($product->product_attribute);
$allValues = array();
foreach ($json as fields) {
foreach ($fields as $field) { foreach ($field as $k => $v) {
$allValues[]= $k.':'.$v; }
}
}
$allCustomfieldsValues = implode (',',$allValues);
}
I dont tested it, so you can have some syntax errors ;)
Hi,
thank you very much.
I corrected the syntax, but the value is empty :'(
Thanks.
Ooups
Try to change json_encode with json_decode a little mistake
It's not working... :(