Home › Forums › Themes Support › Claue › Discount Amount
- This topic has 3 replies, 2 voices, and was last updated 4 years, 1 month ago by Harry.
-
AuthorPosts
-
-
December 7, 2020 at 7:35 pm #39506
Hi Harry,
Hope you are fine. 🙂I am using a custom code to show the discount amount on the product page:
// Show Discount Amount on Product Page add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 ); function change_displayed_sale_price_html( $price, $product ) { // Only on sale products on frontend and excluding min/max price on variable products if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')){ // Get product prices $regular_price = (float) $product->get_regular_price(); // Regular price $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale) // "Saving price" calculation and formatting $saving_price = wc_price( $regular_price - $sale_price ); // Append to the formated html price $price .= sprintf( __(' <p class="saved-sale">Discount: %s</p> ', 'woocommerce' ), $saving_price ); } return $price; }
You can see this here:Â https://look.ir/mesauda-mascara/
Is there any chance to customize this code to show it under the price, here: https://prnt.sc/vxh2ug
Regards.
Rahim Vaziri
CEO & Founder at Look.ir -
December 7, 2020 at 10:26 pm #39511
Hi Rahim,
Please add custom CSS code
.flex.between-xs.middle-xs.price-review { display: inline-block; }
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio -
December 7, 2020 at 11:06 pm #39513
Hi Harry,
Thank you for the answer.After applying the code, this happens:Â https://prnt.sc/vxmcqa
As I said above, I just want to bring the saved priced to the next line. Any solution for this:Â https://prnt.sc/vxh2ug
Regards
Rahim Vaziri
CEO & Founder at Look.ir -
December 9, 2020 at 8:15 am #39523
Hi Rahim,
Please change code to
.flex.between-xs.middle-xs.price-review { display: block; } .price-review .woocommerce-product-rating { float: left; } .saved-sale { display: inline-block; }
Kind regards
Harry
Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio
-
-
AuthorPosts
You must be logged in to reply to this topic.