'jigoshop_cart', 'description' => __( 'Shopping Cart for the sidebar', 'jigoshop' ) ); // Create the widget parent::__construct( 'jigoshop_cart', __( 'Jigoshop: Cart', 'jigoshop' ), $options ); } /** * Widget * * Display the widget in the sidebar * Save output to the cache if empty * * @param array sidebar arguments * @param array instance */ public function widget( $args, $instance ) { // Hide widget if page is the cart if ( is_cart() ) return false; extract( $args ); // Set the widget title $title = apply_filters( 'widget_title', ( $instance['title'] ) ? $instance['title'] : __( 'Cart', 'jigoshop' ), $instance, $this->id_base ); // Print the widget wrapper & title echo $before_widget; echo $before_title . $title . $after_title; // Get the contents of the cart $cart_contents = jigoshop_cart::$cart_contents; // If there are items in the cart print out a list of products if ( ! empty( $cart_contents ) ) { // Open the list echo ''; // Close the list // Print the cart total echo '

'; echo __( ( ( get_option( 'jigoshop_prices_include_tax') == 'yes' ) ? 'Total' : 'Subtotal' ), 'jigoshop' ); echo ': ' . jigoshop_cart::get_cart_total(); echo '

'; do_action( 'jigoshop_widget_cart_before_buttons' ); // Print view cart & checkout buttons echo '

'; echo '' . __( 'View Cart →', 'jigoshop' ) . ''; echo '' . __( 'Checkout →', 'jigoshop' ) . ''; echo '

'; } else { echo '' . __( 'No products in the cart.', 'jigoshop' ) . ''; } // Print closing widget wrapper echo $after_widget; } /** * Update * * Handles the processing of information entered in the wordpress admin * Flushes the cache & removes entry from options array * * @param array new instance * @param array old instance * @return array instance */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; // Save the new values $instance['title'] = strip_tags( $new_instance['title'] ); return $instance; } /** * Form * * Displays the form for the wordpress admin * * @param array instance */ public function form( $instance ) { // Get instance data $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : null; // Widget Title echo "

"; } } // class Jigoshop_Widget_Cart