shopp_cart_taxrate

filters the returned tax rate percentage in the cart.

add_filter( 'shopp_cart_taxrate', [callback] )

@param float $rate the tax rate percentage applied in the cart

Description

filters the returned tax rate percentage in the cart.

Example

// register filter callback
add_filter('shopp_cart_taxrate', 'my_taxrate_filter');

// create filter function
function my_taxrate_filter( $rate ) {
    // Add 1% to all returned rates
    return $rate + 0.01;
}

See Also

  1. Avatar of Nick Ciske

    Remove tax for tax exempt customers (cleaner version):

    // register filter callback
    add_filter('shopp_cart_taxrate', 'taxexempt_filter');
    
    // create filter function
    function taxexempt_filter( $rate ) {
    
        $Customer = shopp_customer();
    
        if( isset($Customer->type) && $Customer->type == 'Tax-Exempt' )
            return 0;
    
        return $rate;
    }
    
    June 1st   #

  2. Avatar of Benjamin Huddleston

    For anyone else out here needing to implement a tax exempt setup without having to make customers register first, here’s how I accomplished that:

    First, add a new order data field

    // Tax-Exempt ID Number
    shopp('checkout','order-data','input=text&name=taxexempt');
    

    Then added the following to my functions.php file:

    // SHOPP TAX FILTER
    // register filter callback
      add_filter('shopp_cart_taxrate', 'my_taxrate_filter');
    
    // create filter function
      function my_taxrate_filter($rate) {
        // get shopp order object
        $Order = ShoppOrder();
        // grab the data portion of it
        $OrderData = $Order->data;
        // retrieve the taxexcept input
        $taxId = $OrderData['taxexempt'];
        // if anything is entered here, set tax rate to 0
        if ($taxId != '') {
          $rate = $rate * 0;
        }
    
        return $rate;
      }
    
    May 3rd   #

  3. Avatar of LeeAnne Egge

    The example here doesn’t work for Shopp 1.3 since $rate is now an object.

    When you print_r($rate); you’ll now get something like this:

    Array ( 
        [4373e4a1] => ShoppItemTax Object ( 
            [label] => Tax 
            [rate] => 0.096 
            [amount] => 0 
            [total] => 0 
            [compound] => off 
        )
    )
    

    So you can’t directly change the rate.

    However, I’ve found this will work for Shopp 1.3:

    
    // register filter callback
    // add_filter( 'shopp_cart_taxrate', 'my_taxrate_filter' ); // deprecated Use shopp_tax_rates
     add_filter( 'shopp_tax_rates', 'my_taxrate_filter' );
    
    // create filter function
    function my_taxrate_filter( $taxrate ) {
           // get the array key and id
            $arrkey = array_keys($taxrate);
        $arrid =  $arrkey[0];
            //  change the rate to whatever you need it to be
        $newrate = $taxrate;
        $localrate = $newrate[$arrid]->rate +.001;
        $newrate[$arrid]->rate = $localrate;
        return $taxrate;
    }
    
    
    February 9th   #

  4. Avatar of TGI

    LeeAnne,

    Thanks for the cheat sheet on that! I was able to get my WA Tax filter working in 1.3.x using that info–it was an issue that previously had me stumped as to why stuff wasn’t returning to the page.

    Thanks,
    KMT

    April 3rd   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.

Skip to toolbar