Hiding the cart widget option now shows the widget if adding to cart via ajax
This commit is contained in:
parent
63443eacb5
commit
4fab179206
|
@ -185,6 +185,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Fixed missing errors on my account
|
||||
* Enhanced variation price display (thanks pixeltrix) and tweaked get_price_html - new filters for variation prices
|
||||
* email_order_items_table image thumbnail support
|
||||
* Hiding the cart widget option now shows the widget if adding to cart via ajax
|
||||
|
||||
= 1.4.4 - 18/02/2012 =
|
||||
* Fix for remove coupon links after ajax update of shipping
|
||||
|
|
|
@ -42,13 +42,13 @@ class WooCommerce_Widget_Cart extends WP_Widget {
|
|||
if ( !empty($instance['title']) ) $title = $instance['title']; else $title = __('Cart', 'woocommerce');
|
||||
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
|
||||
$hide_if_empty = (isset($instance['hide_if_empty']) && $instance['hide_if_empty']) ? '1' : '0';
|
||||
|
||||
if ($hide_if_empty && sizeof($woocommerce->cart->get_cart())==0) return;
|
||||
|
||||
|
||||
echo $before_widget;
|
||||
if ( $title ) echo $before_title . $title . $after_title;
|
||||
|
||||
echo '<ul class="cart_list product_list_widget">';
|
||||
echo '<ul class="cart_list product_list_widget ';
|
||||
if ($hide_if_empty) echo 'hide_cart_widget_if_empty';
|
||||
echo '">';
|
||||
if (sizeof($woocommerce->cart->get_cart())>0) :
|
||||
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) :
|
||||
$_product = $cart_item['data'];
|
||||
|
@ -77,6 +77,17 @@ class WooCommerce_Widget_Cart extends WP_Widget {
|
|||
echo '<p class="buttons"><a href="'.$woocommerce->cart->get_cart_url().'" class="button">'.__('View Cart →', 'woocommerce').'</a> <a href="'.$woocommerce->cart->get_checkout_url().'" class="button checkout">'.__('Checkout →', 'woocommerce').'</a></p>';
|
||||
endif;
|
||||
echo $after_widget;
|
||||
|
||||
if ($hide_if_empty && sizeof($woocommerce->cart->get_cart())==0) {
|
||||
$inline_js = "
|
||||
jQuery('.hide_cart_widget_if_empty').parent().hide();
|
||||
jQuery('body').bind('adding_to_cart', function(){
|
||||
jQuery(this).find('.hide_cart_widget_if_empty').parent().fadeIn();
|
||||
});
|
||||
";
|
||||
|
||||
$woocommerce->add_inline_js( $inline_js );
|
||||
}
|
||||
}
|
||||
|
||||
/** @see WP_Widget->update */
|
||||
|
|
Loading…
Reference in New Issue