News:

Looking for documentation? Take a look on our wiki

Main Menu

Replace product added to cart popup

Started by sandomatyas, February 05, 2021, 07:26:44 AM

Previous topic - Next topic

sandomatyas

I can disable the 'product added to cart' popup but in this case VM redirects to the cart.
Is there a way to replace the popup with something what I don't need to close? Like a javascript growl message, cart module animation etc? When you add to cart lot of products from a list, it would be better not to close a popup after every click but get some info about the success

jenkinhill

You could add a js autoclose to the popup.   Don't know if this method still works - http://forum.virtuemart.net/index.php?topic=107038.msg479530#msg479530
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

pinochico

We add autoclose to button Continue and hidde Close button, because we need, then customer go to cart and finish order (it is priority no. 1).
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

AH

#3
You can do this by adding an override to the JS to your template which auto closes the add to cart popup.

For some businesses, their customers will add multiple items from a category to their order, in this case, having to manually close the popup is not helpful.  That is why adjusting the padded.php and vmprice.js may be useful.

If you look at the file:   components/com_virtuemart/assets/js/vmprices.js   

you will see that the code to autoclose is included - it has just been commented out


function(datas, textStatus) {

         if (datas.stat == 1) {
            var txt = datas.msg;
         } else if (datas.stat == 2) {
            var txt = datas.msg;
         } else {
            var txt = "<H4>" + Virtuemart.vmCartError + "</H4>" + datas.msg;
         }
         if (usefancy) {
            jQuery.fancybox({
               "titlePosition": "inside",
               "transitionIn": "fade",
               "transitionOut": "fade",
               "changeFade": "fast",
               "type": "html",
               "autoCenter": true,
               "closeBtn": false,
               "closeClick": false,
               "content": txt/*,
               "autodimension"   : true,
               "onComplete"   : function () {
                  setTimeout(function(){
                     jQuery.fancybox.close();
                     }, 500);
               }*/
            });


You can remove the /* and */

Changing the 500 value to a larger or smaller value will close the popup more quickly or more slowly


I move my adjusted file to my template directory to prevent it getting overwritten:

templates/mytemplates/js/vmprices.js

Having adjusted this you may also want to change the popup layout - padded.php - to provide simplified information and no buttons (the users can get to the cart using the cart module links and do not need links in the popup)


A very simple option


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

if (
$this->products and is_array($this->products) and count($this->products)>) {
foreach($this->products as $product){
if($product->quantity>0){
echo '<div class="add-to-cart-desc">'.vmText::sprintf('COM_VIRTUEMART_CART_PRODUCT_ADDED',$product->quantity).'</div>';
} else {
if(!empty($product->errorMsg)){
echo '<div>'.$product->errorMsg.'</div>';
}
}
}
}
?>


Regards
A

Joomla 4.4.5
php 8.1