Display add to cart form for each product on the shop page in WooCommerce

Display add to cart form for each product on the shop page in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'woocommerce_after_shop_loop_item', 'wc_display_whole_add_cart_form', 1 );
 
function wc_display_whole_add_cart_form() {
   global $product;
   if ( ! $product->is_purchasable() ) return;
   remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
   add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 11 );
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.