admin管理员组

文章数量:1325236

when product out of stock single page show notify woocommerce, i am doing this code but showing button only archive page, i want to show single page any one help for code .jpg

  add_filter( 'woocommerce_loop_add_to_cart_link', 'filter_loop_add_to_cart_link', 20, 3 );
 function filter_loop_add_to_cart_link( $button, $product, $args = array() ) {
 if( $product->is_in_stock() ) return $button;

// HERE set your button text (when product is not on stock)
$button_text = __('Not available', 'woocommerce');

 return sprintf( '<a class="button disabled" style="%s">%s</a>', $style, $button_text );
}

when product out of stock single page show notify woocommerce, i am doing this code but showing button only archive page, i want to show single page any one help for code https://i.sstatic/4EFd7.jpg

  add_filter( 'woocommerce_loop_add_to_cart_link', 'filter_loop_add_to_cart_link', 20, 3 );
 function filter_loop_add_to_cart_link( $button, $product, $args = array() ) {
 if( $product->is_in_stock() ) return $button;

// HERE set your button text (when product is not on stock)
$button_text = __('Not available', 'woocommerce');

 return sprintf( '<a class="button disabled" style="%s">%s</a>', $style, $button_text );
}
Share Improve this question edited Aug 22, 2020 at 14:19 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Aug 22, 2020 at 10:42 SonglyricstSonglyricst 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

To achieve this into your single page product follow the below guide line. I'm assuming you have copied the woocommerce template into your theme folder. Navigate to the the path yourtheme/woocommerce/templates/single-product/add-to-cart/simple.php You can put your code here.

本文标签: woocommerce offtopicwhen product out of stock single page show button notify woocommerce