/**
* Display QTY Input before add to cart link.
*/
function custom_wc_template_loop_quantity_input() {
// Global Product.
global $product;
// Check if the product is not null, is purchasable, is in stock, and not sold individually.
if ( $product && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
if ( $product->is_type( 'simple' ) ) {
// For simple products.
woocommerce_quantity_input(
array(
'min_value' => 1,
'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity(),
)
);
} elseif ( $product->is_type( 'variable' ) ) {
// For variable products.
woocommerce_variable_add_to_cart();
}
}
}
add_action( 'woocommerce_after_shop_loop_item', 'custom_wc_template_loop_quantity_input', 9 );
/**
* Add JS script in <head/> tag.
*/
function custom_wc_add_qty_change_script() {
?>
<script>
(function ($) {
$(document).on("change", "li.product .quantity input.qty", function (e) {
e.preventDefault();
var add_to_cart_button = $(this).closest("li.product").find("a.add_to_cart_button");
// For AJAX add-to-cart actions.
add_to_cart_button.attr("data-quantity", $(this).val());
// For non-AJAX add-to-cart actions.
add_to_cart_button.attr("href", "?add-to-cart=" + add_to_cart_button.attr("data-product_id") + "&quantity=" + $(this).val());
});
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'custom_wc_add_qty_change_script', 20 );
i’ve been using the plugin “WooCommerce One Page Checkout” from woocommerce.com
the plugin adds a quantity box of each cart item on the checkout page order summary for user to edit cart itmes quantity.
The order summary will be refreshed via ajax after page loaded or quantity updated, but i’ve noticed an issue that the quantity box themed by blocksy is working properly at first, but when the order summary refreshed via ajax, the increment and the decrement button of the quantity box are not functioning afterwards.
I supposed the cause of this issue is the button listener has been reset after ajax reload, how can i register the event listener again after ajax reload? thank you.
]]>Inside elementor: https://pasteboard.co/xKRvvFaChNp5.png
Outside elementor: https://pasteboard.co/8DpFU29PWABP.png
]]>The step of quantity button does not work. The ‘+’ and ‘-‘ button always change only by 1 although I set incremental step of quantity button to 2 or 3. Other themes like StoreFront have no issue with incremental step of quantity button. Can you help?
]]>Your plugin works perfectly fine with the simple products. However we’d like to display the quantity buttons for the variable products as well – mainly on the shop page & the category pages. As I don’t see any settings related to displaying the quantity buttons for the variable products specifically, I wonder what to do now.
So on a very urgent basis, please guide me through as this is a very urgent requirement from the client.
Looking forward to hearing from you at the earliest.
Thanks.
]]>I’m using WordPress 5.6. Now I noticed that my increment/decrement buttons are not working in product detail pages. Any hope??
]]>Hello,
I have a problem with “quantity-button quantity-up”. When I have a product where the customer must select a size or, when the item is in stock there is only one product, the symbol + appears next to the button to add to the cart. It seems like the template hides everything but that selector +.
Can anyone guide me a bit on how to get around this? What file may be reporting this error to review?
Thank you
TEME: Arkhitekton Version: 1.2
WORPRESS: 5.5
WOOCOMMERCE: 4.4.1