最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

woocommerce offtopic - when product out of stock single page show button notify woo-commerce

programmeradmin1浏览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 .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.

发布评论

评论列表(0)

  1. 暂无评论