VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: Toni_Skuli on April 15, 2019, 23:43:45 PM

Title: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 15, 2019, 23:43:45 PM
Hi,

I'm currently working on a website and my intention was to have related products show in the product-details page.
This works fine using the VirtueMart products module and putting it into a productdetails overwrite. This the piece of code I use:
?><div class="Related"><?php
    $modules 
JModuleHelper::getModules('product_related');        
    foreach(
$modules as $mod)
        {
            echo 
JModuleHelper::renderModule($mod);
        }
        
?>
</div>

The problem is that when I choose a variant from the Multi Variant it redirects to a page where I can see the product as in a category view. Which is surprising because when i disable the product module it works fine again.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Studio 42 on April 16, 2019, 00:03:00 AM
You have the customfield related products, you dont need any extra module.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 16, 2019, 00:05:25 AM
thank you for your reply. I know that this is possible and I have tried to do it. The issue is that I end up with the same problem.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Studio 42 on April 16, 2019, 00:17:47 AM
This is template related, because some dev use the same class for related products and product details.
Try to remove the product class ".productdetails-view" in your related products render and check if it work.
Else write in your console(when you display product details)
Virtuemart.containerSelector
And check if you have only 1 element using this class only elsethe script not work properly.
Another way to check is to write in  console.
jQuery(Virtuemart.containerSelector).length
this need to be always = 1 in product details.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 16, 2019, 01:01:03 AM
I ran Virtuemart.containerSelector in the console and it always gives ".productdetails-view" on the product detail page and also when i on click on a related product. For some reason when I choose a variant from the list it redirects to a ".product-container" which I assume should be ".productdetails-view" . I have also checked for jQuery(Virtuemart.containerSelector).length it constantly gives 1 as a response.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Jörgen on April 16, 2019, 06:06:30 AM
Outdated template perhaps? Try with protostar template. Product-container is the class to be used for products.
Jörgen @ Kreativ Fotografi
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 16, 2019, 11:08:07 AM
Thank you for your reply, i tried using the protostar template or a different one but the problem still occurs.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Studio 42 on April 16, 2019, 13:42:54 PM
If the website is public, can you send a link to a product having the problem ?
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 16, 2019, 19:26:17 PM
Well I'm trying to reduce costs ::). Therefore it is on my localhost. I think that the problem is that the multiple variant redirects to the wrong layout but I have no idea why.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Studio 42 on April 16, 2019, 21:12:37 PM
You can use https://www.planethoster.com/en/World-Lite
It's free, you only have to validate it each month.
When you have finish, you can subscribe or simply do not validate again.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 18, 2019, 15:35:44 PM
I have been working on the code and I solved the problem.
In the customfield.php I removed the unset($attribs['data-reload']); from
if(VmConfig::get ('jdynupdate', TRUE)){
      $view = vRequest::getCmd('view','productdetails');
if($view == 'productdetails' or ($customfield->browseajax and $view == 'category')){
$attribs['data-dynamic-update'] = '1';
unset($attribs['data-reload']);
} else {
$view = 'productdetails';
}
}

And now it works like a charm.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Studio 42 on April 18, 2019, 15:44:21 PM
If you have to modify this file, then your template is a little obsolete certainly.
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Jörgen on April 18, 2019, 16:36:00 PM
Funny solution ...
This is from VM 3.4.5.10045

$view = 'productdetails';
$attribs['data-reload'] = '1';
if(VmConfig::get ('jdynupdate', TRUE)){
$view = vRequest::getCmd('view','productdetails');
if($view == 'productdetails' or ($customfield->browseajax and $view == 'category')){
$attribs['data-dynamic-update'] = '1';
unset($attribs['data-reload']);
} else {
$view = 'productdetails';
}
}

To be compared with your code

...
...
if(VmConfig::get ('jdynupdate', TRUE)){
      $view = vRequest::getCmd('view','productdetails');
if($view == 'productdetails' or ($customfield->browseajax and $view == 'category')){
$attribs['data-dynamic-update'] = '1';
unset($attribs['data-reload']);
} else {
$view = 'productdetails';
}
}

The current code would be faulty to ?

Jörgen @ Kreativ Fotografi
Title: Re: Problem when using Multi Variant & VirtueMart Products
Post by: Toni_Skuli on April 19, 2019, 18:27:10 PM
Well, like I stated everthing is kept the same but I removed the 
unset($attribs['data-reload']); line.