Home › Forums › WoodMart support forum › Promotion with a discount label displayed
Promotion with a discount label displayed
- This topic has 4 replies, 2 voices, and was last updated 3 hours, 22 minutes ago by
kruajeng.
-
AuthorPosts
-
March 17, 2025 at 5:19 am #646242
kruajengParticipantI want to set up a product promotion with a discount label displayed as shown in this image.
How do I do that?
Attachments:
You must be logged in to view attached files.March 17, 2025 at 2:23 pm #646439
Aizaz Imtiaz AwanKeymasterHello,
There is no option in the theme settings to display the save price like this. This requires customization, which is beyond our support policy.
I have searched for a possible solution and found a custom function that you can add to your functions.php file. If the provided code does not work as expected, unfortunately, we are unable to modify it further.
Add this to your theme’s functions.php file of the theme.
add_filter('woocommerce_get_price_html', 'custom_sale_savings', 10, 2); function custom_sale_savings($price, $product) { if ($product->is_on_sale()) { $regular_price = $product->get_regular_price(); $sale_price = $product->get_sale_price(); $savings = $regular_price - $sale_price; $price .= '<span class="save-price">Save $' . number_format($savings, 2) . '</span>'; } return $price; }
To style the save price add the following code in Theme Settings > Custom CSS > Global CSS area.
.save-price { display: inline-block; background-color: #ff0000; /* Change to your preferred color */ color: #fff; font-size: 14px; font-weight: bold; padding: 3px 8px; border-radius: 5px; margin-left: 10px; }
Hope this Helps!
Best Regards,
March 17, 2025 at 3:05 pm #646451
kruajengParticipantHello, Aizaz Imtiaz Awan
Could you please tell me
How to remove or change the currency To ฿?
I sell products in Thailand.And I can’t find the functions.php file.
Which menu in the theme is it hidden under? Could you please check?Thank you.
March 17, 2025 at 5:08 pm #646511
Aizaz Imtiaz AwanKeymasterHello,
01. You can modify the currency symbol in the code by replacing “$” with “฿” like this:
add_filter('woocommerce_get_price_html', 'custom_sale_savings', 10, 2); function custom_sale_savings($price, $product) { if ($product->is_on_sale()) { $regular_price = $product->get_regular_price(); $sale_price = $product->get_sale_price(); $savings = $regular_price - $sale_price; $price .= '<span class="save-price">Save ฿' . number_format($savings, 2) . '</span>'; } return $price; }
02. You can use a file manager plugin to edit your wp-config.php file.
Install and activate a https://wordpress.org/plugins/wp-file-manager/
Open the file manager plugin in your WordPress dashboard. Navigate to your website’s root directory and locate the wp-config.php file.
Use the plugin’s code editor to open the file. Search for
define(‘DISALLOW_FILE_EDIT’, true);
and change true to false.Follow this guide: https://theplusaddons.com/blog/how-to-fix-wordpress-theme-file-editor-missing
Best Regards,
March 17, 2025 at 5:49 pm #646518 -
AuthorPosts
- You must be logged in to create new topics. Login / Register