Cart shortcode in popup - do I have to make extra code or it's a theme bug?
The theme is custom, but I'm not the original author - I upgrade the client's website. I need to make a cart as popup. Exactly cart, not mini cart. I mean with plus-minus quantity input, coupons, delivery method choosing, etc. I saw that in other custom themes people make like that - just adding shortcode of the cart to popup. Popups are usually in footer, my too. Simplest that it even can be, I even copied the body class of the cart
<div class="popup-cart d-none">
<div class="popup-cart-wrapper woocommerce-cart">
<div class="popup-mini-cart-close">
<span>×</span>
</div>
<?php echo do_shortcode('[woocommerce_cart]') ?>
</div>
</div>
But I have a bug - it doesn't want to update when I change the quantity. The code for update is the most famous, which I use many years, but I didn't make the cart in popup from zero yet, I made mini cart and saw the full cart in ready themes - so maybe it's because it's not a cart page?
jQuery( function( $ ) {
let timeout;
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click"); // trigger cart update
}, 1000 ); // 1 second delay, half a second (500) seems comfortable too
});
} );
The previous author use plugins, when I prefer to use code - there was ajax cart authoupdate, there is quantity increment and ajax add to cart plugins. I tried to switch off ajax autoupdate and ajax add to cart to see would the famous code update the cart in popup - no, it didn't help
So the main question is - is it important or that script to be exactly on the cart page? Or I should dig in theme what's causing the conflict? Or maybe it's a way to make it work outside of cart page?