woo_widget_cssclass = 'widget_shopping_cart'; $this->woo_widget_description = __( "Display the user's Shopping Cart in the sidebar.", 'woocommerce' ); $this->woo_widget_idbase = 'woocommerce_shopping_cart'; $this->woo_widget_name = __('WooCommerce Shopping Cart', 'woocommerce' ); /* Widget settings. */ $widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description ); /* Create the widget. */ $this->WP_Widget('shopping_cart', $this->woo_widget_name, $widget_ops); } /** @see WP_Widget */ function widget( $args, $instance ) { global $woocommerce; if (is_cart() || is_checkout()) return; extract($args); 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'; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; echo ''; if (sizeof($woocommerce->cart->get_cart())>0) : echo '

' . __('Subtotal', 'woocommerce') . ': '. $woocommerce->cart->get_cart_total() . '

'; do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); echo '

'.__('View Cart →', 'woocommerce').' '.__('Checkout →', 'woocommerce').'

'; endif; echo $after_widget; if ($hide_if_empty && sizeof($woocommerce->cart->get_cart())==0) { $inline_js = " jQuery('.hide_cart_widget_if_empty').closest('.widget').hide(); jQuery('body').bind('adding_to_cart', function(){ jQuery(this).find('.hide_cart_widget_if_empty').closest('.widget').fadeIn(); }); "; $woocommerce->add_inline_js( $inline_js ); } } /** @see WP_Widget->update */ function update( $new_instance, $old_instance ) { $instance['title'] = strip_tags(stripslashes($new_instance['title'])); $instance['hide_if_empty'] = !empty($new_instance['hide_if_empty']) ? 1 : 0; return $instance; } /** @see WP_Widget->form */ function form( $instance ) { $hide_if_empty = isset( $instance['hide_if_empty'] ) ? (bool) $instance['hide_if_empty'] : false; ?>

/>