Home / Forums / Basel support forum / How to display “You save” for sale price?
Home › Forums › Basel support forum › How to display “You save” for sale price?
How to display “You save” for sale price?
- This topic has 5 replies, 2 voices, and was last updated 3 weeks, 4 days ago by
Tuomo.
-
AuthorPosts
-
November 7, 2025 at 6:43 pm #694882

TuomoParticipantHi there,
I tried to add these codes to the child theme functions.php, but for some reason these didn’t work:function you_save_text_for_product() { global $product; // works for Simple and Variable type $regular_price = get_post_meta( $product->get_id(), '_regular_price', true ); // 36.32 $sale_price = get_post_meta( $product->get_id(), '_sale_price', true ); // 24.99 if( !empty($sale_price) ) { $saved_amount = $regular_price - $sale_price; $currency_symbol = get_woocommerce_currency_symbol(); $percentage = round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 ); ?> <p class="you_save_price">You save: <?php echo $currency_symbol .''. number_format($saved_amount, 2, '.', ''); ?></p> <?php } } add_action( 'woocommerce_single_product_summary', 'you_save_text_for_product', 12 ); // hook priorityI tried to add this for the variable products:
// For product variations (on variable products) add_filter( 'woocommerce_available_variation', 'variable_product_saving_amount', 10, 3 ); function variable_product_saving_amount( $data, $product, $variation ) { if( $variation->is_on_sale() ) { $saved_amount = $data['display_regular_price'] - $data['display_price']; $percentage = round( $saved_amount / $data['display_regular_price'] * 100 ); $data['price_html'] .= '<p id="you_save_price">'. __("You Save") .': ' . wc_price($saved_amount) . ' ('.$percentage.'%)</p>'; } return $data; }This to CSS:
.you_save_price { background: #f9f9f9; padding: 10px; border: 1px dashed #ddd; width: 150px; font-size: 14px; font-weight: 600; margin-top: 10px; }How can I make this work properly? Is this part wrong on the code: woocommerce_single_product_summary or the 12 ); // hook priority ?
I took the codes from here:
https://wpsimplehacks.com/simple-woocommerce-hacks/#hack-6-how-to-display-you-save-for-sale-price
https://www.youtube.com/watch?v=auGuzky6QWIBest Regards,
Tuomo NurkkalaNovember 10, 2025 at 11:29 am #695109
Artem TemosKeymasterHello
Thank you for reaching out with your question. Unfortunately, custom code modifications like adding a “You save” display for sale prices fall outside the scope of our theme support.
Kind Regards
November 11, 2025 at 5:00 pm #695440
TuomoParticipantOkay 🙁
Are you using on the product pages the normal woocommerce hooks like woocommerce_single_product_summary ?November 11, 2025 at 5:01 pm #695441
TuomoParticipantAnd is your hook for variable products woocommerce_available_variation ?
November 12, 2025 at 10:35 am #695581
Artem TemosKeymasterBoth hooks are related to the WooCommerce plugin, and our theme doesn’t remove them.
Kind Regards
November 12, 2025 at 11:16 am #695599
TuomoParticipantOkay, so these codes should work. I have to check if there is some problem with the hooks priority. Maybe there might be some issue.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register