Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,146
- Plugin Contributions:
- 56
Post #101 by lat9
The jQuery selector used by this plugin to trigger the add_cart.php file's load is too general, as it applies to *any * submit action within the cart_quantity form. If you've got a plugin (like one of my premium offerings) that adds another submit-type action within the form, then the AJAX Add to Cart takes over ***all ***those actions.
The correction requires a minor change to the selector present in /includes/templates/YOUR_TEMPLATE/jscript/jscript_script_loader.php, changing from:
<?php
if (ZX_AJAX_CART_STATUS == 'true') {
if(ZX_AJAX_CART_JQUERY == 'true') echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>';
?>
<script src="<?php echo DIR_WS_TEMPLATES.$template_dir ; ?>/jscript/jquery.form.min.js"></script>
<script language="javascript">
function showview(c){var b="#"+c;jQuery(b).show()}function hideview(c){var b="#"+c;jQuery(b).hide()}function closecart(){jQuery("#carttopcontainer").fadeOut(400)}function startHover(){jQuery("#carttopcontainer").fadeIn(600)}function endHover(){jQuery("#carttopcontainer").fadeOut(600)}function ajax_cart(){var a="shoppingcart.php";jQuery("#carttopcontainer").load(a),jQuery("html, body").animate({scrollTop:0},"slow"),jQuery("#carttopcontainer").fadeIn(400),jQuery("#carttopcontainer").delay(<?php echo ZX_AJAX_CART_FADE_DELAY; ?>).animate({height:"hide",opacity:"hide"},200).mouseover(function(){jQuery(this).stop(!0,!1).animate({opacity:1},200)}).mouseleave(function(){jQuery(this).animate({height:"hide",opacity:"hide"},200)})}function add_prod(a){jQuery.ajax({type:"POST",url:"add_prod.php",data:"products_id="+a,success:function(b){"success"==b.status?(jQuery("#cartBoxListWrapper2").html(b.cart),jQuery("#topcartinner").html(b.cart_top),jQuery("#bottomfinaltotal2").html(b.total)):"error"==b.status},dataType:"json"})}function showRequest(c,b,a){var d=jQuery.param(c);document.getElementById("loadBar").innerHTML='<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'bar-loading.gif', 'Loading...'); ?>';return true}function strpos(b,c,d){var a=(b+"").indexOf(c,(d||0));return a===-1?false:a}function showResponse(a,b){var c=strpos(a,"Warning",5);if(c>0){document.getElementById("loadBar").innerHTML="";document.getElementById("button_cart").innerHTML='<br /><?php echo TEXT_AJAX_CART_ERROR_NOT_ADDED; ?>'}else{document.getElementById("loadBar").innerHTML="";ajax_cart()}}$(document).ready(function(){var a={target:"#topcartinner",url:"add_to_cart.php",type:"POST",beforeSubmit:showRequest,success:showResponse};$("#cart_quantity").submit(function(){$(this).ajaxSubmit(a);return false})});
</script>
<?php } ?>
to
<?php
if (ZX_AJAX_CART_STATUS == 'true') {
if(ZX_AJAX_CART_JQUERY == 'true') echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>';
?>
<script src="<?php echo DIR_WS_TEMPLATES.$template_dir ; ?>/jscript/jquery.form.min.js"></script>
<script language="javascript">
function showview(c){var b="#"+c;jQuery(b).show()}function hideview(c){var b="#"+c;jQuery(b).hide()}function closecart(){jQuery("#carttopcontainer").fadeOut(400)}function startHover(){jQuery("#carttopcontainer").fadeIn(600)}function endHover(){jQuery("#carttopcontainer").fadeOut(600)}function ajax_cart(){var a="shoppingcart.php";jQuery("#carttopcontainer").load(a),jQuery("html, body").animate({scrollTop:0},"slow"),jQuery("#carttopcontainer").fadeIn(400),jQuery("#carttopcontainer").delay(<?php echo ZX_AJAX_CART_FADE_DELAY; ?>).animate({height:"hide",opacity:"hide"},200).mouseover(function(){jQuery(this).stop(!0,!1).animate({opacity:1},200)}).mouseleave(function(){jQuery(this).animate({height:"hide",opacity:"hide"},200)})}function add_prod(a){jQuery.ajax({type:"POST",url:"add_prod.php",data:"products_id="+a,success:function(b){"success"==b.status?(jQuery("#cartBoxListWrapper2").html(b.cart),jQuery("#topcartinner").html(b.cart_top),jQuery("#bottomfinaltotal2").html(b.total)):"error"==b.status},dataType:"json"})}function showRequest(c,b,a){var d=jQuery.param(c);document.getElementById("loadBar").innerHTML='<?php echo zen_image(DIR_WS_TEMPLATE_IMAGES . 'bar-loading.gif', 'Loading...'); ?>';return true}function strpos(b,c,d){var a=(b+"").indexOf(c,(d||0));return a===-1?false:a}function showResponse(a,b){var c=strpos(a,"Warning",5);if(c>0){document.getElementById("loadBar").innerHTML="";document.getElementById("button_cart").innerHTML='<br /><?php echo TEXT_AJAX_CART_ERROR_NOT_ADDED; ?>'}else{document.getElementById("loadBar").innerHTML="";ajax_cart()}}$(document).ready(function(){var a={target:"#topcartinner",url:"add_to_cart.php",type:"POST",beforeSubmit:showRequest,success:showResponse};$([B]'#cartAdd > input[type="submit"], #cartAdd > input[type="image"]').click[/B](function(){$(this).ajaxSubmit(a);return false})});
</script>
<?php } ?>