Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在woocommerce中显示快捷码而不是缺货消息_Php_Wordpress_Woocommerce_Shortcode - Fatal编程技术网

Php 在woocommerce中显示快捷码而不是缺货消息

Php 在woocommerce中显示快捷码而不是缺货消息,php,wordpress,woocommerce,shortcode,Php,Wordpress,Woocommerce,Shortcode,当一个变量缺货时,我更喜欢通过一个短代码显示一个表单,而不是原来的文本消息 您可以在此处看到原始缺货消息(选择大小48) 我知道如何添加插件文件并通过我的子主题更改它们。此任务有一个过滤器挂钩。将此添加到functions.php: add_filter( 'woocommerce_get_availability_text', 'my_woocommerce_get_availability_text', 10, 2 ); function my_woocommerce_get_availab

当一个变量缺货时,我更喜欢通过一个短代码显示一个表单,而不是原来的文本消息

您可以在此处看到原始缺货消息(选择大小48)


我知道如何添加插件文件并通过我的子主题更改它们。

此任务有一个过滤器挂钩。将此添加到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;
}

谢谢如何在那里显示此文本+快捷码表单?当我将dreamweaver粘贴到函数文件中时,它确实显示了一个错误。我在“my_woocommerce_get_availability_text”(第一行)之后添加了一个逗号,但当我在线上传时,网站变成了空白。Argl抱歉。我的代码中有严重错误。现在应该可以了。