VirtueMart 3.2.2 does not show product attributes in cart

Started by Jumbo!, May 18, 2017, 10:40:20 AM

Previous topic - Next topic

Jumbo!

VirtueMart 3.2.2 does not show selected cart attributes in cart.

To fix this problem follow the below steps.

Copy - components/com_virtuemart/sublayouts/customfield.php
to
templates/YOUR-JOOMLA-TEMPLATE/html/com_virtuemart/sublayouts/customfield.php


Now open - templates/YOUR-JOOMLA-TEMPLATE/html/com_virtuemart/sublayouts/customfield.php

Find the following codes between lines 693 to 698:

//We need this here to ensure that broken customdata of order items is shown updated info, or at least displayed,
if($prodcustom->is_cart_attribute or $prodcustom->is_input){
if(!isset($variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id])){
$variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id] = $prodcustom->virtuemart_customfield_id;
}
}


Replace above by:

if($prodcustom->is_cart_attribute && !$prodcustom->is_input) {
if(!isset($variantmods[$prodcustom->virtuemart_custom_id]) || !is_array($variantmods[$prodcustom->virtuemart_custom_id])) {
$variantmods[$prodcustom->virtuemart_custom_id] = array();
}

$variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id] = false;
}


Save the file. Now it should work fine.

Milbo

I am sorry for this error, your solution is not wrong for your case, but does not reflect the other cases. I tested the solution with a string, but with a list and not with a combined dropdown

Please redownload the package. I reupped it. I found the error some hours after the release, written here http://forum.virtuemart.net/index.php?topic=137491.msg481445#msg481445

The right solution is

//The problem here is that a normal value and an array can be valid. The function should complement, or update the product. So we are not allowed
//to override existing values. When the $variantmods array is not set for the key, then we add an array, when the customproto is used more than one time
//the missing values are added with an own key.
if(!isset($variantmods[$prodcustom->virtuemart_custom_id]) or (is_array($variantmods[$prodcustom->virtuemart_custom_id]) and !isset($variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id])) ){
$variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id] = $prodcustom->virtuemart_customfield_id;
//vmdebug('foreach $variantmods $customfield_id ', $prodcustom->virtuemart_custom_id, $prodcustom->virtuemart_customfield_id,$variantmods);
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jumbo!

Okay. I will test it.

But you should define $variantmods[$prodcustom->virtuemart_custom_id] as array before directly assigning $variantmods[$prodcustom->virtuemart_custom_id][$prodcustom->virtuemart_customfield_id].