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

Problem when using Multi Variant & VirtueMart Products

Started by Toni_Skuli, April 15, 2019, 23:43:45 PM

Previous topic - Next topic

Toni_Skuli

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.

Studio 42

You have the customfield related products, you dont need any extra module.

Toni_Skuli

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.

Studio 42

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.

Toni_Skuli

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.

Jörgen

Outdated template perhaps? Try with protostar template. Product-container is the class to be used for products.
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Toni_Skuli

Thank you for your reply, i tried using the protostar template or a different one but the problem still occurs.

Studio 42

If the website is public, can you send a link to a product having the problem ?

Toni_Skuli

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.

Studio 42

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.

Toni_Skuli

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.

Studio 42

If you have to modify this file, then your template is a little obsolete certainly.

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Toni_Skuli

Well, like I stated everthing is kept the same but I removed the 
unset($attribs['data-reload']); line.