Author Topic: VirtueMart 3.2.2 does not show product attributes in cart  (Read 97 times)

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 562
  • Software Developer {PHP, JavaScript, jQuery, ...}
    • www.virtueplanet.com
  • VirtueMart Version: 3.2.2
VirtueMart 3.2.2 does not show product attributes in cart
« on: May 18, 2017, 10:40:20 am »
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:

Code: [Select]
//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:

Code: [Select]
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 8986
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: VirtueMart 3.2.2 does not show product attributes in cart
« Reply #1 on: May 18, 2017, 10:54:12 am »
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
Code: [Select]
//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);
}
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 562
  • Software Developer {PHP, JavaScript, jQuery, ...}
    • www.virtueplanet.com
  • VirtueMart Version: 3.2.2
Re: VirtueMart 3.2.2 does not show product attributes in cart
« Reply #2 on: May 18, 2017, 10:58:06 am »
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].