Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xlplugins/8ee29c50bf8a2dfe3d619f5c5bba1b1c to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/8ee29c50bf8a2dfe3d619f5c5bba1b1c to your computer and use it in GitHub Desktop.
Simple Sticky Add To Cart For WooCommerce conflict with fkcart
add_action( 'wp_footer', function () {
if ( ! is_product() ) {
return;
}
?>
<script>
document.addEventListener('click', function (e) {
var a = e.target.closest('a.wsatc-add-to-cart');
var wrap = document.getElementById('wsatc-stick-cart-wrapper');
if (!a || !wrap || !wrap.classList.contains('simple')) {
return;
}
e.preventDefault();
var wsQty = document.querySelector('.wsatc-qty-field');
var formQty = document.querySelector('form.cart .qty');
if (wsQty && formQty) {
formQty.value = wsQty.value;
}
var btn = document.querySelector('form.cart .single_add_to_cart_button');
if (btn) {
btn.click();
}
}, true);
</script>
<?php
}, 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment