Home Forums WoodMart support forum Dynamic discount – fixed discount tax is missing

Dynamic discount – fixed discount tax is missing

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #582119

    Marco
    Participant

    We try to use the dynamic discount table with a fixed discount but the discount value shows without tax included.
    We use net prices in the backend and show gross prices in the frontend.
    The discount table shows only the net discount, but should display a gross price.
    Is there any chance to display the column discount with gross price? maybe a code snippet?

    Thanks

    #582141

    Marco
    Participant

    eg. The Product gross Price is 279,00 €
    In the in the backend discount table I added
    from 2 to 2 fixed discount 4,20 (net discount)
    In the frontend the table shows
    2 Price per unit 274,00 (gross price) Discount 4,20 (net discount)
    Instead of showing the net discount 4,20 it should display the gross discount 5,00

    Hope it is clear now what I mean

    #582146

    Artem Temos
    Keymaster

    Hello,

    Please provide us with your admin access so we can log in and check this on your end.

    Thank you in advance.

    #582182

    Marco
    Participant

    Find the Login Data in the private section

    #582184

    Artem Temos
    Keymaster

    Sorry, but we can’t enter your dashboard with the URL provided.

    #582190

    Marco
    Participant

    Soory, we use 2FA, I’ve disabled it temporary, please try again

    #582394

    Artem Temos
    Keymaster

    Try to edit the file wp-content\themes\woodmart\inc\integrations\woocommerce\modules\dynamic-discounts\class-frontend.php and replace the code

    'value' => 'amount' === $rules['_woodmart_discount_type'] ? apply_filters( 'woodmart_pricing_amount_discounts_value', $rules['_woodmart_discount_amount_value'] ) : $rules['_woodmart_discount_percentage_value'],

    with this

    'value' => 'amount' === $rules['_woodmart_discount_type'] ? apply_filters( 'woodmart_product_pricing_amount_discounts_value', $rules['_woodmart_discount_amount_value'] ) : $rules['_woodmart_discount_percentage_value'],

    And after this, add the following snippet to the function.php file in your child theme

    add_filter(
    	'woodmart_pricing_amount_discounts_value',
    	function ( $discount ) {
    		global $product;
    
    		if ( ! $product || ! wc_tax_enabled() || 'incl' !== get_option( 'woocommerce_tax_display_shop' ) ) {
    			return $discount;
    		}
    
    		$tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
    		$taxes     = WC_Tax::calc_tax( $discount, $tax_rates, false );
    
    		if ( 'yes' === get_option( 'woocommerce_tax_round_at_subtotal' ) ) {
    			$taxes_total = array_sum( $taxes );
    		} else {
    			$taxes_total = array_sum( array_map( 'wc_round_tax_total', $taxes ) );
    		}
    
    		$discount_price = $discount + $taxes_total;
    
    		if ( ! is_numeric( $discount_price ) ) {
    			$discount_price = floatval( $discount_price );
    		}
    
    		$discount_price = round( $discount_price, wc_get_price_decimals() );
    
    		return $discount_price;
    	}
    );
    #582498

    Marco
    Participant

    Thanks for your fast and reliable support.
    It works perfect!

    #582574

    Artem Temos
    Keymaster

    You are welcome. Feel free to contact us if you have any further questions.

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

The topic ‘Dynamic discount – fixed discount tax is missing’ is closed to new replies.