Skip to content

Instantly share code, notes, and snippets.

@gvgvgvijayan
Created June 28, 2020 09:52
Show Gist options
  • Save gvgvgvijayan/9f903dafddc85a19c980a776b000ae2e to your computer and use it in GitHub Desktop.
Save gvgvgvijayan/9f903dafddc85a19c980a776b000ae2e to your computer and use it in GitHub Desktop.
<?php
add_action('wp_footer', 'update_quantity_attribute');
function update_quantity_attribute()
{
?>
<script type='text/javascript'>
let simpleProductInput = document.querySelectorAll('.product-type-simple .quantity > input');
simpleProductInput.forEach(dom => {
dom.addEventListener('input', e => {
e.target.parentElement.nextElementSibling.setAttribute('data-quantity', e.target.value);
});
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment