Ajaxify shopping cart in volusion

后端 未结 1 1172
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 11:30

I am working on a template on Volusion, my question is, can the \"add to cart\" button there be ajaxified?

相关标签:
1条回答
  • 2021-01-27 11:53

    Assuming your store has the admin config variable "Enable Add To Cart Popup" turned on, you can simply provide a link like shown below, anywhere in your template and when the user clicks on it it will add the item via Ajax so as long as the item does not have options or is not a gift certificate. Volusion has built in scripts which run which handle this automatically provided the config variable is turned on.

    <a class="unbind" href="/ShoppingCart.asp?ProductCode=xyz">
       <img border="0" align="absmiddle" src="/v/vspfiles/templates/248/images/buttons/btn_addtocart_small.gif">
    </a>
    

    Add the following to the before the </head> tag in your template and use the above link to add the item. Each time you click on it it will add a quantity of one to the cart. There will be no visual feedback that the item has been added, per your request.

    <script type="text/javascript">
    $(function() {
    $('.unbind').unbind()
        .click(function() {
            var product_code = $(this).attr('href').substr($(this).attr('href').lastIndexOf('=') + 1).toUpperCase();
            $.ajax({
                type: "POST",
                url: '/ProductDetails.asp?ProductCode=' + product_code + '&btnaddtocart=btnaddtocart&AjaxError=Y&batchadd=Y',
                data: 'ProductCode=' + product_code + '&QTY.' + product_code + '=1'
            });
            return false;
        });
    });
    </script>
    

    If you want the soft cart to popup after an item is clicked on use the HTML shown above (change the product code accordingly) and use the following code.

    <script type="text/javascript">
    $(function() {
        $('.unbind').unbind()
            .click(function() {
                var qstr = 'ProductCode=' + global_URL_Encode_Current_ProductCode + '&QTY.' + global_URL_Encode_Current_ProductCode + '=1&ReplaceCartID=&ReturnTo=&e=&btnaddtocart.x=5&btnaddtocart.y=5';
                SoftAddSingleItem(global_URL_Encode_Current_ProductCode, 1, qstr);
                return false;
            });
    });
    </script>
    
    0 讨论(0)
提交回复
热议问题