Put quantity input and add to cart on every thumbnail in shop archive in Divi theme

I am trying to build archive page where I will have add to cart and quantity input that will send amount of items in cart.

So I tried several option like using this code snipped that is working on other site but it is not working in Divi wordpress theme from Eleganththemes.

Read More
add_action( 'woocommerce_after_shop_loop_item', 'my_custom_quantity_field', 9 ); 
function my_custom_quantity_field() {
global $product;
if ( ! $product->is_sold_individually() ) 
woocommerce_quantity_input( array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', 1, $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->backorders_allowed() ? '' : $product->get_stock_quantity(), $product )
));    `

It only shows me then quantity input when I am using this code.

I also tried to put this function in below:

add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart' );

When I do that add to cart show on the page on every item, but it doesn’t pick up the quantity number when I click on addtocart, do you have some solution for this, it would be really helpful.

Related posts