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
1 Answer
Reset to default 0To 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.