Author Topic: Multi variant trouble, child not showing parent option in select  (Read 293 times)

gallego.d

  • Beginner
  • *
  • Posts: 1
  • A beginner
Multi variant trouble, child not showing parent option in select
« on: September 20, 2017, 21:34:27 pm »
Hi, not sure if it's a migration issue or a bug,

the thing is that i've seen this on a couple of posts, only from previous versions, and suggested workarounds doesn't work,
having a J3.7.5 VM 3.2.4 multilanguage site, with previous products (with multivariants and child products from a J3.6.5 VM3.0.16), newly created multivariant products don't work as expected,

- previously the 'main' product had it's own price, images, etc, and the child created by using the multivariant had their own prices/ranges, images, etc., by entering the product the visitor can switch between products (by using two predefined ranges such as size and colour) , this still applies to older products with more complex multivariants,

- now, repeating the same process we end up with a product that, when selecting size, the parent option disappear from the select,
for example, for a product with a multivariant like this
book01 - A6 (this is the main product)
book02 - A5 (the child)
when the customer enters the book01, it can choose the A5 size, but once chosen it can never go back (select the original A6 option)

any help in troubleshooting / patching this issue would be much appreciated,

Jordi B

  • Beginner
  • *
  • Posts: 6
Re: Multi variant trouble, child not showing parent option in select
« Reply #1 on: November 22, 2017, 09:31:19 am »
Hi, Same problem in one dimension multivariant in new version VM 3.2.4.
When I select the child the main product can't be selected any more.
Have you solved it?


Jordi B

  • Beginner
  • *
  • Posts: 6
Re: Multi variant trouble, child not showing parent option in select
« Reply #2 on: November 22, 2017, 13:20:12 pm »
Hi,
 I find  the problem.
In the last version 3.2.4 in customfield.php sublayout the code for ignore in the select multivariant the products not published was changed from the old code:
Code: [Select]
$q = 'SELECT `virtuemart_product_id` FROM #__virtuemart_products WHERE product_parent_id = "'.$customfield->virtuemart_product_id.'" and ( published = "0" ';
if($stockhandle == 'disableit_children'){
$q .= ' OR (`product_in_stock` - `product_ordered`) <= "0"';
}
$q .= ');';
$db = JFactory::getDbo();
$db->setQuery($q);
$ignore = $db->loadColumn();
//vmdebug('my q '.$q,$ignore);

foreach($customfield->options as $product_id=>$variants){

if($ignore and in_array($product_id,$ignore)){
//vmdebug('$customfield->options Product to ignore, continue ',$product_id);
continue;
}


to the new code:
Code: [Select]
$q = 'SELECT `virtuemart_product_id` FROM #__virtuemart_products WHERE product_parent_id = "'.$customfield->virtuemart_product_id.'" and ( published = "1" ';
if($stockhandle == 'disableit_children'){
$q .= ' AND (`product_in_stock` - `product_ordered`) > "0" ';
}
$q .= ');';
$db = JFactory::getDbo();
$db->setQuery($q);
$avail = $db->loadColumn();
array_unshift($avail,$product->virtuemart_product_id);


foreach($customfield->options as $product_id=>$variants){
static $counter = 0;
if(!in_array($product_id,$avail)){
vmdebug('$customfield->options Product to ignore, continue ',$product_id);
continue;
}

This code isn't work on the child products because in $avail array never find the parent product id, and so in the child we can't select the parent option.
I've copied the sublayout to my template and I add the code:
Code: [Select]
array_unshift($avail,$product->product_parent_id);
so in $avail array we have always self product id, need when the product is the parent, and parent id, need  when product is  a child.
I don't know if this can affect other cases, but in my case work ok.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7637
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Multi variant trouble, child not showing parent option in select
« Reply #3 on: November 23, 2017, 23:28:15 pm »
is this not the bug fixed?

Changes in VirtueMart version 3.2.6

Very important fix for multivariants, which lost in some conditions the parent option, when changing to a child.
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jordi B

  • Beginner
  • *
  • Posts: 6
Re: Multi variant trouble, child not showing parent option in select
« Reply #4 on: November 27, 2017, 11:25:44 am »
Yes, in my case in VM 3.2.6 the issue was fixed.
Thanks