$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Apply a discount percentage to regular price WooCommerce by function|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Apply a discount percentage to regular price WooCommerce by function

matteradmin8PV0评论

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;
}
Post a comment

comment list (0)

  1. No comments so far