Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active May 21, 2022 10:14
Show Gist options
  • Save wplit/4eb77f2ba19cf32cd681e23a78f1cc7c to your computer and use it in GitHub Desktop.
Save wplit/4eb77f2ba19cf32cd681e23a78f1cc7c to your computer and use it in GitHub Desktop.
trigger offcanvas opening when item added to cart (add to code block and just change the class or ID to match your offcanvas)
(function($){
let offCanvas = '.my-offcanvas'; // Change to your offcanvas selector (class or ID)
/* When item is added to cart */
$( document.body ).on( 'added_to_cart', function(){
/* Toggle the classes to open the offcanvas */
$('html,body').addClass('off-canvas-toggled');
$(offCanvas).addClass('oxy-off-canvas-toggled');
$('.added_to_cart').remove();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment