Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discount assigned to role doesn't work if you do not have a general discount on the product (no role) #128

Open
rafaelcalero opened this issue Jun 26, 2020 · 0 comments

Comments

@rafaelcalero
Copy link
Contributor

rafaelcalero commented Jun 26, 2020

Describe the bug
Discount assigned to role doesn't work if you do not have a general discount on the product (no role).

To Reproduce
Steps to reproduce the behavior:

  1. Create product without discount in woocommerce.
  2. Assign regular price and sale price to a role.
  3. The user with that role will get the discounted price, but will not receive the crossed out price indicating that it is on sale.

Expected behavior
They should appear in the format wc_format_sale_price()

Additional context

The problem seems to be in the WooCommerce_Role_Based_Price_Product_Pricing->get_price_html_wc3();

$product->is_on_sale() returns false because for wordpress that product is not on sale.

             ...
        } else if( $product->is_on_sale() && $prices['min_reg_price'] === $prices['max_reg_price'] ) {
            $price = wc_format_sale_price(wc_price($prices['max_reg_price']), wc_price($prices['min_price']));
        } else {
             ....

A possible fix could be add filter on the woocommerce_product_is_on_sale hook and modify this value for products that they have different regular and sale price or perhaps put one more condition in that same function.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant