简体   繁体   English

在woocommerce中显示短代码而不是缺货消息

[英]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.

相关问题 woocommerce 短代码与库存数量 - woocommerce shortcode with stock quantity 排除短代码 [products 或 product_category] WooCommerce 中的缺货产品 - Excluding out of stock products in shortcode [products or product_category] WooCommerce 检查 WooCommerce 产品(简单或变体)是否有库存并将标签显示为短代码 - Check if WooCommerce product (simple or variations) are in stock and display label as shortcode 通过 Woocommerce 上的短代码有条件地显示自定义库存数量 - Display custom stock quantity conditionally via shortcode on Woocommerce 在 Woocommerce 最近的产品简码中仅显示“库存”产品 - Display only "in stock" products in Woocommerce Recent Products shortcode 如果 WooCommerce 短代码没有返回产品,则显示一条消息 - Display a message if there are no products returned for a WooCommerce shortcode WooCommerce 产品在实际没有缺货时显示“缺货”消息 - WooCommerce products showing “Out of stock” message when not actually out of stock 在目录视图 Woocommerce 上显示“缺货” - Display " Out of Stock " on catalog view Woocommerce 显示特定类别的缺货产品 - Woocommerce - Display out of stock products on specific category - Woocommerce 如果 WooCommerce 中未启用“管理库存”,则显示自定义库存消息 - Display custom stock message if "Manage Stock" is not enabled in WooCommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM