Don't show view cart message on cart page. Closes #3877

This commit is contained in:
Mike Jolley 2013-10-04 12:21:22 +01:00
parent 599da4f20f
commit 8f196130ff
3 changed files with 8 additions and 7 deletions

View File

@ -65,7 +65,7 @@ jQuery(document).ready(function($) {
$thisbutton.addClass('added');
// View cart text
if ( $thisbutton.parent().find('.added_to_cart').size() == 0 )
if ( ! wc_add_to_cart_params.is_cart && $thisbutton.parent().find('.added_to_cart').size() == 0 )
$thisbutton.after( ' <a href="' + wc_add_to_cart_params.cart_url + '" class="added_to_cart" title="' + wc_add_to_cart_params.i18n_view_cart + '">' + wc_add_to_cart_params.i18n_view_cart + '</a>' );
// Replace fragments

View File

@ -1 +1 @@
jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity")};e("body").trigger("adding_to_cart",[t,n]);e.post(wc_add_to_cart_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");if(n.error&&n.product_url){window.location=n.product_url;return}if(wc_add_to_cart_params.cart_redirect_after_add=="yes"){window.location=wc_add_to_cart_params.cart_url;return}t.removeClass("loading");fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+wc_add_to_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.addClass("added");t.parent().find(".added_to_cart").size()==0&&t.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})});
jQuery(document).ready(function(e){e(document).on("click",".add_to_cart_button",function(){var t=e(this);if(t.is(".product_type_simple")){if(!t.attr("data-product_id"))return!0;t.removeClass("added");t.addClass("loading");var n={action:"woocommerce_add_to_cart",product_id:t.attr("data-product_id"),quantity:t.attr("data-quantity")};e("body").trigger("adding_to_cart",[t,n]);e.post(wc_add_to_cart_params.ajax_url,n,function(n){if(!n)return;var r=window.location.toString();r=r.replace("add-to-cart","added-to-cart");if(n.error&&n.product_url){window.location=n.product_url;return}if(wc_add_to_cart_params.cart_redirect_after_add=="yes"){window.location=wc_add_to_cart_params.cart_url;return}t.removeClass("loading");fragments=n.fragments;cart_hash=n.cart_hash;fragments&&e.each(fragments,function(t,n){e(t).addClass("updating")});e(".shop_table.cart, .updating, .cart_totals").fadeTo("400","0.6").block({message:null,overlayCSS:{background:"transparent url("+wc_add_to_cart_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});t.addClass("added");!wc_add_to_cart_params.is_cart&&t.parent().find(".added_to_cart").size()==0&&t.after(' <a href="'+wc_add_to_cart_params.cart_url+'" class="added_to_cart" title="'+wc_add_to_cart_params.i18n_view_cart+'">'+wc_add_to_cart_params.i18n_view_cart+"</a>");fragments&&e.each(fragments,function(t,n){e(t).replaceWith(n)});e(".widget_shopping_cart, .updating").stop(!0).css("opacity","1").unblock();e(".shop_table.cart").load(r+" .shop_table.cart:eq(0) > *",function(){e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" id="add1" class="plus" />').prepend('<input type="button" value="-" id="minus1" class="minus" />');e(".shop_table.cart").stop(!0).css("opacity","1").unblock();e("body").trigger("cart_page_refreshed")});e(".cart_totals").load(r+" .cart_totals:eq(0) > *",function(){e(".cart_totals").stop(!0).css("opacity","1").unblock()});e("body").trigger("added_to_cart",[fragments,cart_hash])});return!1}return!0})});

View File

@ -131,11 +131,12 @@ class WC_Frontend_Scripts {
) ) );
wp_localize_script( 'wc-add-to-cart', 'wc_add_to_cart_params', apply_filters( 'wc_add_to_cart_params', array(
'ajax_url' => WC()->ajax_url(),
'ajax_loader_url' => apply_filters( 'woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
'i18n_view_cart' => esc_attr__( 'View Cart &rarr;', 'woocommerce' ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
'ajax_url' => WC()->ajax_url(),
'ajax_loader_url' => apply_filters( 'woocommerce_ajax_loader_url', $assets_path . 'images/ajax-loader@2x.gif' ),
'i18n_view_cart' => esc_attr__( 'View Cart &rarr;', 'woocommerce' ),
'cart_url' => get_permalink( woocommerce_get_page_id( 'cart' ) ),
'is_cart' => is_cart(),
'cart_redirect_after_add' => get_option( 'woocommerce_cart_redirect_after_add' )
) ) );
wp_localize_script( 'wc-add-to-cart-variation', 'wc_add_to_cart_variation_params', apply_filters( 'wc_add_to_cart_variation_params', array(