Woo side cart compatible

Woo side cart compatible

/**
 * Before adding this do the following
 *
 * 1. Create a template override for the file
 * [PLUGIN_PATH]/woocommerce-side-cart-premium/public/partials/xoo-wsc-content.php
 * by copying the file to [ACTIVE_THEME_FOLDER_PATH]/woocommerce/xoo-wsc-content.php
 *
 * 2. add the code snippet in line number 10
 *
 * do_action( 'woocommerce_before_mini_cart' );
 * 
 **/

add_action('wp_footer', function(){
    ?>
    <script type="text/javascript">
        jQuery( document ).ready(function() {
            jQuery(document.body).on('xoo_wsc_cart_updated added_to_cart',function() {
                jQuery( document.body ).trigger( 'wc_fragment_refresh' );
            });
        });
    </script>
    <?php
}, 11);
add_action('woocommerce_before_mini_cart', function(){
    if (!WC()->cart->is_empty()){
        WC()->cart->calculate_totals();
    }
});