Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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_Hook Woocommerce - Fatal编程技术网

Php 隐藏woocommerce单一产品变体产品中的删除(然后是折扣)价格

Php 隐藏woocommerce单一产品变体产品中的删除(然后是折扣)价格,php,wordpress,woocommerce,hook-woocommerce,Php,Wordpress,Woocommerce,Hook Woocommerce,我没有找到正确的方法来摆脱这种价格→ 在woocommerce单一产品页面中 我尝试了许多在Internet上可用的方法,但无法摆脱任何remove\u操作请尝试下面的代码片段 add_filter('woocommerce_get_price_html', "wt_hide_regular_price", 99, 2); function wt_hide_regular_price($price, $product) { if(!is_cart() && !is_

我没有找到正确的方法来摆脱这种价格→

在woocommerce单一产品页面中


我尝试了许多在Internet上可用的方法,但无法摆脱任何
remove\u操作

请尝试下面的代码片段

add_filter('woocommerce_get_price_html', "wt_hide_regular_price", 99, 2);

function wt_hide_regular_price($price, $product)
{
    if(!is_cart() && !is_checkout() && !is_ajax()){
        if ($product->is_type('simple') || $product->is_type('variation')) {
            return wt_regular_price_for_product($price, $product);
        } 
    }
        return $price;            

}

function wt_regular_price_for_product($price, $product){
    return wc_price($product->get_price());
}

如果我想隐瞒全部价格呢?(打折,等于正常价格和销售价格)我认为在这种情况下→ <代码>返回wc_价格($product->get_价格())将成为→ 只需
return
@wocommerce115编辑答案-我希望这对你的情况没问题。顺便说一下,如果对你有用,请接受→ <代码>返回wc_价格($product->get_价格())它将打印或返回哪个价格?常规还是销售?@wocommerce115产品现行价格(如有销售,则为常规销售价格)