Merge pull request #22541 from woocommerce/pr/20830
Init cart widget when added to sidebar via the customizer
This commit is contained in:
commit
5f5272ba2e
|
@ -165,4 +165,18 @@ jQuery( function( $ ) {
|
|||
$( document.body ).on( 'adding_to_cart', function() {
|
||||
$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
|
||||
});
|
||||
|
||||
// Customiser support.
|
||||
var hasSelectiveRefresh = (
|
||||
'undefined' !== typeof wp &&
|
||||
wp.customize &&
|
||||
wp.customize.selectiveRefresh &&
|
||||
wp.customize.widgetsPreview &&
|
||||
wp.customize.widgetsPreview.WidgetPartial
|
||||
);
|
||||
if ( hasSelectiveRefresh ) {
|
||||
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
|
||||
refresh_cart_fragment();
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,6 +36,10 @@ class WC_Widget_Cart extends WC_Widget {
|
|||
),
|
||||
);
|
||||
|
||||
if ( is_customize_preview() ) {
|
||||
wp_enqueue_script( 'wc-cart-fragments' );
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
@ -54,6 +58,10 @@ class WC_Widget_Cart extends WC_Widget {
|
|||
|
||||
$hide_if_empty = empty( $instance['hide_if_empty'] ) ? 0 : 1;
|
||||
|
||||
if ( empty( $instance['title'] ) ) {
|
||||
$instance['title'] = __( 'Cart', 'woocommerce' );
|
||||
}
|
||||
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
if ( $hide_if_empty ) {
|
||||
|
|
Loading…
Reference in New Issue