• Resolved jmoriart

    (@jmoriart)


    I wanted to apply a sliding tax scale to my events, so I edited the get_price_with_tax function in classes/em-ticket.php.

    	function get_price_with_tax( $format = false ){
    	    $pretaxPrice = $this->get_price_without_tax();
            $adjustableTaxRate = 12;
            if ( $pretaxPrice >= 30 ) {
                $adjustableTaxRate = 11;
            }
            if ($pretaxPrice >= 40) {
                $adjustableTaxRate = 10;
            }
            if ($pretaxPrice >= 50) {
                $adjustableTaxRate = 9;
            }
            if ($pretaxPrice >= 60) {
                $adjustableTaxRate = 8;
            }
            // etc...
            $price = ceil($pretaxPrice * (1 + $adjustableTaxRate/100)); // ceil(); rounds up
    	    if( $format ) return $this->format_price($price);
    	    return $price; 
    	}

    This code is working quite well and it displays the price exactly as expected on the front end. However, when you actually book an event, it charges the credit card using the tax value entered in Settings>Bookings>PricingOptions.

    Is there another file or function from which the final price is passed that would be pulling this tax rate directly from the Settings value?

    I am using Braintree as a payment gateway using https://gist.github.com/wturnerharris/7443520 I think it gets the amount from
    'amount' => $EM_Booking->get_price(false, false, true),
    What are those boolean parameters? Maybe I could tell it to get
    'amount' => $EM_Booking->get_price_with_tax(),
    but I don’t know what params to put in there, or if that’s even accurate at all.

    Anyone know where to point me?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you’ll need to get the price without tax and then add your sliding tax value to that. Events Manager only stores one tax amount so it’ll be wrong for what you’re trying to do.

    Thread Starter jmoriart

    (@jmoriart)

    Okay, yea my payment gateway plugin was getting the price separately I guess and storing it in an array $args[‘amount’]. So I just replaced that value with a new one, basically recalculating my code above.
    I’m not sure why the function get_price wasn’t using my edited code, but this work around does the trick.
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tax applied in two different places?’ is closed to new replies.