0

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.stack.imgur.com/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 );
}

1 Answer 1

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.

2
  • not work on this page function code Aug 22, 2020 at 11:34
  • I didn't mean by put that code into that template. You need to put just the button with just the condition. Aug 22, 2020 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.