WC_Widget_Cart

Shopping Cart Widget.

Defined (1)

The class is defined in the following location(s).

/includes/widgets/class-wc-widget-cart.php  
  1. class WC_Widget_Cart extends WC_Widget { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7. $this->widget_cssclass = 'woocommerce widget_shopping_cart'; 
  8. $this->widget_description = __( "Display the user's cart in the sidebar.", 'woocommerce' ); 
  9. $this->widget_id = 'woocommerce_widget_cart'; 
  10. $this->widget_name = __( 'WooCommerce cart', 'woocommerce' ); 
  11. $this->settings = array( 
  12. 'title' => array( 
  13. 'type' => 'text',  
  14. 'std' => __( 'Cart', 'woocommerce' ),  
  15. 'label' => __( 'Title', 'woocommerce' ),  
  16. ),  
  17. 'hide_if_empty' => array( 
  18. 'type' => 'checkbox',  
  19. 'std' => 0,  
  20. 'label' => __( 'Hide if cart is empty', 'woocommerce' ),  
  21. ),  
  22. ); 
  23.  
  24. parent::__construct(); 
  25.  
  26. /** 
  27. * Output widget. 
  28. * @see WP_Widget 
  29. * @param array $args 
  30. * @param array $instance 
  31. */ 
  32. public function widget( $args, $instance ) { 
  33. if ( apply_filters( 'woocommerce_widget_cart_is_hidden', is_cart() || is_checkout() ) ) { 
  34. return; 
  35.  
  36. $hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1; 
  37.  
  38. $this->widget_start( $args, $instance ); 
  39.  
  40. if ( $hide_if_empty ) { 
  41. echo '<div class="hide_cart_widget_if_empty">'; 
  42.  
  43. // Insert cart widget placeholder - code in woocommerce.js will update this on page load 
  44. echo '<div class="widget_shopping_cart_content"></div>'; 
  45.  
  46. if ( $hide_if_empty ) { 
  47. echo '</div>'; 
  48.  
  49. $this->widget_end( $args );