Created
June 27, 2020 12:37
-
-
Save gvgvgvijayan/3c85d7cf2af13e4a84e9ad7b622f7514 to your computer and use it in GitHub Desktop.
This gist is used in the tutorial https://www.vijayan.in/how-to-add-quantity-input-in-shop-page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2); | |
function quantity_inputs_for_woocommerce_loop_add_to_cart_link($html, $product) | |
{ | |
if ($product && $product->is_type('simple') && $product->is_purchasable() && $product->is_in_stock() && !$product->is_sold_individually()) { | |
woocommerce_quantity_input(array(), $product); | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment