Answer the question
In order to leave comments, you need to log in
How to disconnect the "Add to Cart" button from the button with the choice of the number of products?
Hello.
I have an "Add to Cart" button in the product card and a field with a choice of the number of products (as usual) next to it. Question: how to disconnect this button, for example, add it to the product description, but what would it also work with the product quantity field?
Answer the question
In order to leave comments, you need to log in
As an option, you can do this:
1. Hide the quantity field via css
.single-product .quantity .qty {
display: none;
}
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 45 ); //В сторфронт выводим после мета описания
add_action('woocommerce_single_product_summary', 'fink_new_qty_add_to_cart', 30 ); //Добавляем новое поле кол-ва туда где была кнопка добавления в корзину
function fink_new_qty_add_to_cart() {
echo '<input type="number" class="new_qty" value="1">';
?>
<script>
jQuery(document).ready(function($) {
$('.new_qty').on('change', function(e) {
var qty = $(this);
$('.quantity .qty').val(qty.val());
});
});
</script>
<?php
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question