Apply a discount percentage to regular price WooCommerce by function

admin2025-06-05  0

I need to show a discounted sum as a percentage of regular price using in WooCommerce. Original and stroked price + discounted price (of 10%). Eg.: 100 90

I've tried a lot of plugins and they discount effectively, but I need to SHOW to customers (in product and category pages) the original sum (regular price) and the discounted price (the real prices are already managed by a rental plugin).

I need to show a discounted sum as a percentage of regular price using in WooCommerce. Original and stroked price + discounted price (of 10%). Eg.: 100 90

I've tried a lot of plugins and they discount effectively, but I need to SHOW to customers (in product and category pages) the original sum (regular price) and the discounted price (the real prices are already managed by a rental plugin).

Share Improve this question edited Dec 6, 2018 at 13:57 butlerblog 5,1413 gold badges28 silver badges44 bronze badges asked Dec 19, 2017 at 16:10 ArDiEmArDiEm 411 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Ok, maibe I got it:

add_filter('woocommerce_get_price_html', 'custom_price', 10, 2);
function custom_price( $price, $product ) {
  $price = 'from ';
  $price .= '<del>' . woocommerce_price($product->regular_price *= 1) . '</del> ';
  $price .= woocommerce_price($product->regular_price *= 0.9);
    $price .= ' per day';
  return $price;
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749123774a316565.html

最新回复(0)