1 <?php
2 3 4 5 6 7 8 9 10 11 12
13
14 if ( ! defined( 'ABSPATH' ) ) exit;
15
16 class WC_Widget_Cart extends WC_Widget {
17
18 19 20
21 public function __construct() {
22 $this->widget_cssclass = 'woocommerce widget_shopping_cart';
23 $this->widget_description = __( "Display the user's Cart in the sidebar.", 'woocommerce' );
24 $this->widget_id = 'woocommerce_widget_cart';
25 $this->widget_name = __( 'WooCommerce Cart', 'woocommerce' );
26 $this->settings = array(
27 'title' => array(
28 'type' => 'text',
29 'std' => __( 'Cart', 'woocommerce' ),
30 'label' => __( 'Title', 'woocommerce' )
31 ),
32 'hide_if_empty' => array(
33 'type' => 'checkbox',
34 'std' => 0,
35 'label' => __( 'Hide if cart is empty', 'woocommerce' )
36 )
37 );
38 parent::__construct();
39 }
40
41 42 43 44 45 46 47 48 49
50 public function widget( $args, $instance ) {
51
52 extract( $args );
53
54 if ( is_cart() || is_checkout() ) return;
55
56 $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Cart', 'woocommerce' ) : $instance['title'], $instance, $this->id_base );
57 $hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1;
58
59 echo $before_widget;
60
61 if ( $title )
62 echo $before_title . $title . $after_title;
63
64 if ( $hide_if_empty )
65 echo '<div class="hide_cart_widget_if_empty">';
66
67
68 echo '<div class="widget_shopping_cart_content"></div>';
69
70 if ( $hide_if_empty )
71 echo '</div>';
72
73 echo $after_widget;
74 }
75 }
76
77 register_widget( 'WC_Widget_Cart' );