News:

Looking for documentation? Take a look on our wiki

Main Menu

Related products in addtocard pop up window

Started by roman5527, August 23, 2018, 12:39:20 PM

Previous topic - Next topic

roman5527

Hi. I want edit related products in addtocard pop up windows.

I want show always only products from one categorie. How i can edit code ?

Thanks

roman5527

Or how i can load module in this pp up window ?

Studio 42

File is here : JOOMLA_FOLDER/components/com_virtuemart/views/cart/tmpl/padded.php
Of course, it's better to do an override in your template

roman5527

Thanks i know .

But any idea how i load module here ? Or products from one categories ?

thanks

Studio 42

<?php $module JModuleHelper::getModule('mod_NAME''Module title'); 
echo 
JModuleHelper::renderModule($module); ?>

Where mod_NAME is the  folder name(or joomla name) of the module eg. mod_virtuemart_product and 'Module title' the title you have set in the back-end.

roman5527

Thanks . But i paste this code  i have this error in console : http://prntscr.com/kmts41

and pop up dont work , i dont see pop up windows.

can you help me fix it ?


thanks.

Studio 42

If you have already inside <?php ?> you dont need to add it and of course you have to respect the HTML DOM, and module need to be exist and set in Joomla modules list.

roman5527

Hi, my padded.php file is here :

<?php
/**
*
* Layout for the add to cart popup
*
* @package VirtueMart
* @subpackage Cart
* @author Max Milbers
*
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2013 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: cart.php 2551 2010-09-30 18:52:40Z milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
echo 
'<div class="left">';
if(
$this->products){
$productModel VmModel::getModel('Product');
    
$product_images $productModel->getProduct($product->virtuemart_product_idtruefalse,true,$product->quantity);
    
$productModel->addImages($product_images,1);
foreach($this->products as $product){
if($product->quantity>0){
echo '<img class="image-pop" src="'.JURI::base(true).'/'.$product_images->images[0]->getFileUrlThumb().'" />';
echo '<h4>'.vmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->product_name,$product->quantity).'</h4>';
} else {
if(!empty($product->errorMsg)){
echo '<h4>'.$product->errorMsg.'</h4>';
//echo '<h4>'.vmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->product_name).'</h4><div>'.$product->errorMsg.'</div>';
}
}

}
}
echo 
'</div>';

echo 
'<a class="continue reset button" href="#" >' JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
echo 
'<a class="showcart floatright button" href="'  .JRoute::_("index.php?option=com_virtuemart&view=cart").'">' JText::_('COM_VIRTUEMART_CART_SHOW') . '</a>';

/*   Calling Joomla Module in Virtuemart product page */
 /*  $modules =&  JModuleHelper::getModules('vm-addtocart-position');
   foreach ($modules as $module)
   {
  echo JModuleHelper::renderModule($module);
   }*/
   
$module JModuleHelper::getModule('mod_vm2_products''Skuska'); 
echo 
JModuleHelper::renderModule($module);

?>



and module is enable and assigned to all pages.

But it is JS error.

Any idea ?

Thanks

Studio 42

#8
Problem is not getFileUrlThumb ? i was thinking it was removed in Virtuemart 3.2 ? But not sure

Try this code
<?php
/**
*
* Layout for the add to cart popup
*
* @package VirtueMart
* @subpackage Cart
* @author Max Milbers
*
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2013 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: cart.php 2551 2010-09-30 18:52:40Z milbo $
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access'); ?>

<div class="left">
<?php if($this->products){
$productModel VmModel::getModel('Product');
    
$product_images $productModel->getProduct($product->virtuemart_product_idtruefalse,true,$product->quantity);
    
$productModel->addImages($product_images,1);
foreach($this->products as $product){
if($product->quantity>0){ ?>

<img class="image-pop" src="<?php echo JURI::root().$product_images->images[0]->getFileUrlThumb() ?>" />
<h4><?php echo JvmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->product_name,$product->quantity?></h4>
<?php } else {
if(!empty($product->errorMsg)){  ?>

<h4><?php echo $product->errorMsg ?></h4>
<?php //echo '<h4>'.vmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->product_name).'</h4><div>'.$product->errorMsg.'</div>';
}
}

}
?>

</div>
<a class="continue reset button" href="#" ><?php echo JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING'?></a>
<a class="showcart floatright button" href="<?php echo JRoute::_("index.php?option=com_virtuemart&view=cart"?>"><?php echo JText::_('COM_VIRTUEMART_CART_SHOW'?></a>
<?php 
// load modules/mod_vm2_products with title  Skuska    
$module JModuleHelper::getModule('mod_vm2_products''Skuska'); 
echo 
JModuleHelper::renderModule($module);

?>



roman5527

Thank you very mutch .

But problem is not solved.

i try your code and i see this error : http://prntscr.com/koifag

thanks

Studio 42

You dont have a javscript error, it's only that jquery try to load the page and you have error 500(PHP error)
You should check the error displayed in your browser console>network but this is a typical syntax error.
Try to comment this lines and see if it work
//$module = JModuleHelper::getModule('mod_vm2_products', 'Skuska');
//echo JModuleHelper::renderModule($module);
But if you  do it yourself, you should learn some PHP tutorial for beginner and how to debug PHP/Joomla

roman5527

Hi. Thanks

But i add your code i dont see pop-up window and product dont add to cart.

When i comment this rows All is ok

Please where is problem?

Thanks

Studio 42

Activate PHP debug and check the response in your browser console.

roman5527

Hi, i enable show error in joomla configuration to "develop" and i see this in browser console : http://prntscr.com/kp31py

thannks


Jörgen

The errors are quite Self explanatory. Take away your facebook plugin and check server log file for 500 error.

Regards
Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.