Home › Forums › WoodMart support forum › Discount and promo price
Discount and promo price
- This topic has 7 replies, 2 voices, and was last updated 3 years, 2 months ago by
Elise Noromit.
-
AuthorPosts
-
December 7, 2021 at 2:00 pm #337491
QuentinParticipantHello,
I have 2 requests with you theme :
1 – I have a product with this price : 449,99€. This product is on sale, the sale price is 379,99€.
It’s 15,5% off
Product 1 : link in private content Why the website display -16% ? I need to display the real % or round below so as not to lie to customers2 – Same thing, for the variables products. The discount (%) display is the big one. I need to display « up to x% off », this is possible ?
Product 2 : link in private content3 – Same, the discount is display on the variables products, and on each variations while the discount is only on 1 variation. Can I display only on the variation with the discount ?
Product 3 : link in private contentThanks
December 8, 2021 at 12:29 am #337572
Elise NoromitMemberHello,
The percentage is rounded as it is not space enough to show the decimals. As for the sales price for variable products, this is the Woocommerce functionality and WoodMart cannot influence or change that. The product grid shows just variable products. Each variation may have its own discount. Wooommerce does not provide the option to change the discount depending on the variation chosen in the grid.
If you have any questions please feel free to contact us.
Best Regards
December 8, 2021 at 8:03 am #337662
QuentinParticipantHello,
Ok. but Can I round below the % ?
December 8, 2021 at 2:55 pm #337809
Elise NoromitMemberHello,
Please add this code to the functions.php of the child theme:
function woodmart_product_label() { global $product; $output = array(); $product_attributes = woodmart_get_product_attributes_label(); $percentage_label = woodmart_get_opt( 'percentage_label' ); if ( $product->is_on_sale() ) { $percentage = ''; if ( $product->get_type() == 'variable' && $percentage_label ) { $available_variations = $product->get_variation_prices(); $max_percentage = 0; foreach ( $available_variations['regular_price'] as $key => $regular_price ) { $sale_price = $available_variations['sale_price'][ $key ]; if ( $sale_price < $regular_price ) { $percentage = floor( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 ); if ( $percentage > $max_percentage ) { $max_percentage = $percentage; } } } $percentage = $max_percentage; } elseif ( ( $product->get_type() == 'simple' || $product->get_type() == 'external' || $product->get_type() == 'variation' ) && $percentage_label ) { $percentage = floor( ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100 ); } if ( $percentage ) { $output[] = '<span class="onsale product-label">-' . $percentage . '%' . '</span>'; } else { $output[] = '<span class="onsale product-label">' . esc_html__( 'Sale', 'woodmart' ) . '</span>'; } } if ( ! $product->is_in_stock() ) { $output[] = '<span class="out-of-stock product-label">' . esc_html__( 'Sold out', 'woodmart' ) . '</span>'; } if ( $product->is_featured() && woodmart_get_opt( 'hot_label' ) ) { $output[] = '<span class="featured product-label">' . esc_html__( 'Hot', 'woodmart' ) . '</span>'; } if ( woodmart_get_opt( 'new_label' ) && woodmart_is_new_label_needed( get_the_ID() ) ) { $output[] = '<span class="new product-label">' . esc_html__( 'New', 'woodmart' ) . '</span>'; } if ( $product_attributes ) { foreach ( $product_attributes as $attribute ) { $output[] = $attribute; } } $output = apply_filters( 'woodmart_product_label_output', $output ); if ( $output ) { woodmart_enqueue_inline_style( 'woo-mod-product-labels' ); $shape = woodmart_get_opt( 'label_shape' ); if ( 'rectangular' === $shape ) { woodmart_enqueue_inline_style( 'woo-mod-product-labels-rect' ); } if ( 'rounded' === $shape ) { woodmart_enqueue_inline_style( 'woo-mod-product-labels-round' ); } echo '<div class="product-labels labels-' . $shape . '">' . implode( '', $output ) . '</div>'; } }
Best Regards
December 8, 2021 at 4:49 pm #337843
QuentinParticipantHello,
I added the code but it doesn’t work. Are you sure ?
Thanks
December 9, 2021 at 10:19 am #338043
Elise NoromitMemberHello,
We have edited the code provided above. Please try to copy it again and paste, it should work.
Best Regards
December 9, 2021 at 10:25 am #338046
QuentinParticipantHello,
Perfect, it’s work.
Thank you !
December 9, 2021 at 10:30 am #338047
Elise NoromitMemberYou are welcome! We are here to help.
Wish you a wonderful day!
-
AuthorPosts
The topic ‘Discount and promo price’ is closed to new replies.
- You must be logged in to create new topics. Login / Register