What about new VM3 cart object? Cannot get $product->customfields in vmpsplugin

Started by Adwans, June 11, 2016, 22:44:34 PM

Previous topic - Next topic

Adwans

Hello!
In VM2 in vmpsplugin I had:
protected function getOrderWeight (VirtueMartCart $cart, $to_weight_unit) {
..
foreach ($cart->products as $product) {
...
$kustoms = trim($product->customfields);

After move to VM3:
$kustoms = trim($product->customfields);
causes the Warning:
trim() expects parameter 1 to be string, array given in /home/..../administrator/components/com_virtuemart/plugins/vmpsplugin.php on line 641
How can I get product's customfields now (not all CF but the choosen, it was a String value in VM2) ? If I understand well, it is an array now? Could somebody explain this new cart object?

*********** EDITED: 13.06
Plugins is not the best place for echoing/var_dumping... Now, after cart object var_dumping - I know that old customfields String value is removed from the object.
You can only manipulate with the object "nodes"  - So I did:
$nr_cf_wymiar  = intVal($cart->cartProductsData[$i++]["customProductData"][24]);
$wart_cf_wymiar = "";
foreach($product->customfields as $cf){
if ($cf->virtuemart_customfield_id == $nr_cf_wymiar) {
$wart_cf_wymiar = $cf->customfield_value; break;
}
}
where 24 is for particular CF "type" (virtuemart_custom_id)

Any other ideas? If it is ok, can be marked as SOLVED  :)