Show Woocommerce minicart widget in checkout page sidebar? And, how to make this update secure by overriding widget?

The cart widget isn’t showing because it’s configured to not show on the cart and checkout page. If you want to change that take a look at class-wc-widget-cart.php, there you find the following line:

if ( is_cart() || is_checkout() ) return;  

Change it to:

if ( is_cart() ) return;  

To show the widget on the checkout page.

Note: This will be, if done in the plugins/woocommerce/classes/widgets folder, overwritten on updates.


Edit: Additional information how to override widget and make changes update secure
Source: http://www.skyverge.com/blog/overriddin-woocommerce-widgets/ (Option 5)

  1. Duplicate class-wc-widget-cart.php;
  2. Copy the duplicate into a folder inside your theme, for example: cust_woo_widgets
  3. Make above changes to the file;
  4. Additionally make the following change to the widget duplicate:

    class Custom_WooCommerce_Widget_Cart extends WooCommerce_Widget_Cart {
      function widget( $args, $instance ) {
    // copy the widget function from woocommerce/classes/widgets/class-wc-widget-cart.php
      }
    }
    
  5. Put following code into your functions.php:

    add_action( 'widgets_init', 'override_woocommerce_widgets', 15 );
    function override_woocommerce_widgets() { 
      if ( class_exists( 'WooCommerce_Widget_Cart' ) ) {
        unregister_widget( 'WooCommerce_Widget_Cart' ); 
        include_once( 'cust_woo_widgets/widget-cart.php' );
        register_widget( 'Custom_WooCommerce_Widget_Cart' );
      } 
    }
    

Note: See source for more information; untested.

Leave a Comment

tech