News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Multi variant trouble, child not showing parent option in select

Started by gallego.d, September 20, 2017, 21:34:27 PM

Previous topic - Next topic

gallego.d

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

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

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:

$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:

$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:

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

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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jordi B