[英]Display shortcode instead of out of stock message in woocommerce
When a variable is out of stock, I would prefer to display a form through a shortcode, instead of the original text message.当变量缺货时,我更愿意通过短代码而不是原始文本消息显示表单。
You can see the original out of stock message here (select size 48) http://teste.marianoshoes.com/product/artigo/您可以在此处查看原始缺货消息(选择尺码 48) http://teste.marianoshoes.com/product/artigo/
I know how to add the plugin files and change them through my child theme.我知道如何添加插件文件并通过我的子主题更改它们。
There is a filter hook excatly for this task.这个任务有一个过滤器钩子。 Add this to your functions.php:将此添加到您的functions.php:
add_filter( 'woocommerce_get_availability_text', 'my_woocommerce_get_availability_text', 10, 2 );
function my_woocommerce_get_availability_text( $availability, $product) {
if ( ! $product->is_in_stock() ) {
if (function_exists('iphorm_popup')) {
$availability = iphorm_popup(4, 'Change this to the text or HTML that will trigger the popup');
} else {
$availability = 'Your out of stock text here';
}
}
return $availability;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.