Skip to content

Instantly share code, notes, and snippets.

@AshlinRejo
Last active April 23, 2019 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshlinRejo/72ac334f3ff34897a6747cb57f9fd857 to your computer and use it in GitHub Desktop.
Save AshlinRejo/72ac334f3ff34897a6747cb57f9fd857 to your computer and use it in GitHub Desktop.
Woo Discount: 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();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment