Home Forums WoodMart support forum Discount and promo price

Discount and promo price

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #337491

    Quentin
    Participant

    Hello,

    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 customers

    2 – 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 content

    3 – 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 content

    Thanks

    #337572

    Hello,

    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

    #337662

    Quentin
    Participant

    Hello,

    Ok. but Can I round below the % ?

    #337809

    Hello,

    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

    #337843

    Quentin
    Participant

    Hello,

    I added the code but it doesn’t work. Are you sure ?

    Thanks

    #338043

    Hello,

    We have edited the code provided above. Please try to copy it again and paste, it should work.

    Best Regards

    #338046

    Quentin
    Participant

    Hello,

    Perfect, it’s work.

    Thank you !

    #338047

    You are welcome! We are here to help.

    Wish you a wonderful day!

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Discount and promo price’ is closed to new replies.