【问题标题】:Hide striked(and then discounted) Price in woocommerce single product variation product在 woocommerce 单一产品变体产品中隐藏罢工(然后打折)价格
【发布时间】:2019-10-15 16:08:58
【问题描述】:

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

在woocommerce单品页面中。

我尝试了许多互联网上可用的方法,但无法摆脱任何remove_action

【问题讨论】:

    标签: php wordpress woocommerce hook-woocommerce


    【解决方案1】:

    试试下面的代码 sn-p。

    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());
    }
    

    【讨论】:

    • 如果我想隐藏整个价格怎么办? (罢工和折扣,等于正常价格和销售价格)
    • 我认为在那种情况下这个→return wc_price($product->get_price());将变成→只是return
    • @wocommerce115 编辑了答案-我希望这对您的情况很好。如果它对你有用,请接受
    • 顺便问一下 → return wc_price($product->get_price()); 打印或返回哪个价格?普通的还是特价的?
    • @wocommerce115 产品有效价格(如果打折,则销售价格正常)
    猜你喜欢
    • 2015-12-11
    • 2019-12-20
    • 2017-09-01
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 2018-07-18
    • 2018-07-18
    • 2019-07-23
    相关资源
    最近更新 更多