【问题标题】:I want to display the sale price of variable product on the product page when the regular price and sale price of product are same.How can I do this?当产品的正常价格和销售价格相同时,我想在产品页面上显示可变产品的销售价格,我该怎么做?
【发布时间】:2016-11-17 09:25:23
【问题描述】:

这个问题与woocommerce有关。我已经更改了class_wc_product_variation.php 中的 get_price_html(),使得正常价格和销售价格之间没有比较,并且销售价格独立于正常价格。但是当我输入正常价格和销售价格的值相同时,价格不会显示在产品页面中。函数代码如下,另外我在class-wc-product-grouped.php文件中更改了同一文件夹中的另一个函数。

public function get_price_html() {

        $price =  woocommerce_price( $this->sale_price ) ;

        if($this->sale_price!=$this->regular_price && $this->sale_price==$this->regular_price)

        $price = apply_filters( 'woocommerce_variation_sale_price_html', $price, $this );

        return $price;

}

在我更改的函数的 else 部分

function is_on_sale{
    return !empty( $this->sale_price ) && $this->sale_price == $this->price || $this->sale_price == $this->regular_price ? true : false;
}

这个函数位于class-wc-product-grouped.php

【问题讨论】:

    标签: php woocommerce


    【解决方案1】:

    只是一个观察,您的 if 条件似乎总是返回 false。

    它要求 1. 销售价格和正常价格不相等 AND 2. 销售价格和正常价格相等。很矛盾

    【讨论】:

    • 我完全删除了 if 条件,那么当我保持正常和销售价格相同时,销售价格也不会显示。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    • 1970-01-01
    相关资源
    最近更新 更多