/includes/widgets/class-wc-widget-cart.php

  1. <?php 
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) { 
  4. exit; 
  5.  
  6. /** 
  7. * Shopping Cart Widget. 
  8. * 
  9. * Displays shopping cart widget. 
  10. * 
  11. * @author WooThemes 
  12. * @category Widgets 
  13. * @package WooCommerce/Widgets 
  14. * @version 2.3.0 
  15. * @extends WC_Widget 
  16. */ 
  17. class WC_Widget_Cart extends WC_Widget { 
  18.  
  19. /** 
  20. * Constructor. 
  21. */ 
  22. public function __construct() { 
  23. $this->widget_cssclass = 'woocommerce widget_shopping_cart'; 
  24. $this->widget_description = __( "Display the user's cart in the sidebar.", 'woocommerce' ); 
  25. $this->widget_id = 'woocommerce_widget_cart'; 
  26. $this->widget_name = __( 'WooCommerce cart', 'woocommerce' ); 
  27. $this->settings = array( 
  28. 'title' => array( 
  29. 'type' => 'text',  
  30. 'std' => __( 'Cart', 'woocommerce' ),  
  31. 'label' => __( 'Title', 'woocommerce' ),  
  32. ),  
  33. 'hide_if_empty' => array( 
  34. 'type' => 'checkbox',  
  35. 'std' => 0,  
  36. 'label' => __( 'Hide if cart is empty', 'woocommerce' ),  
  37. ),  
  38. ); 
  39.  
  40. parent::__construct(); 
  41.  
  42. /** 
  43. * Output widget. 
  44. * 
  45. * @see WP_Widget 
  46. * 
  47. * @param array $args 
  48. * @param array $instance 
  49. */ 
  50. public function widget( $args, $instance ) { 
  51. if ( apply_filters( 'woocommerce_widget_cart_is_hidden', is_cart() || is_checkout() ) ) { 
  52. return; 
  53.  
  54. $hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1; 
  55.  
  56. $this->widget_start( $args, $instance ); 
  57.  
  58. if ( $hide_if_empty ) { 
  59. echo '<div class="hide_cart_widget_if_empty">'; 
  60.  
  61. // Insert cart widget placeholder - code in woocommerce.js will update this on page load 
  62. echo '<div class="widget_shopping_cart_content"></div>'; 
  63.  
  64. if ( $hide_if_empty ) { 
  65. echo '</div>'; 
  66.  
  67. $this->widget_end( $args ); 
.