/**
  * Return true if the order should be taxed
  *
  * @return boolean
  */
 public function isTaxed($isShippingTaxed = null)
 {
     $s = $this->getShipping();
     if (count($s)) {
         $taxRate = new Cart66TaxRate();
         $isTaxed = $taxRate->loadByZip($s['zip']);
         if ($isTaxed == false) {
             $isTaxed = $taxRate->loadByState($s['state']);
         }
         $this->_taxRate = $taxRate;
         $taxShipping = $taxRate->tax_shipping;
         return $isShippingTaxed == null ? $isTaxed : $taxShipping;
     } else {
         throw new Exception(__('Unable to determine tax rate because shipping data is unavailable', 'cart66'));
     }
 }
Esempio n. 2
0
                 } catch (Cart66Exception $e) {
                     $exception = Cart66Exception::exceptionMessages($e->getCode(), $e->getMessage(), array('Error Number: ' . $response['L_ERRORCODE0'], $response['L_LONGMESSAGE0']));
                     echo Cart66Common::getView('views/error-messages.php', $exception);
                 }
             }
         }
     }
     // End if doexpresscheckout
 } elseif (isset($_GET['token']) || isset($_GET['PayerID'])) {
     $token = Cart66Common::getVal('token');
     $payerId = Cart66Common::getVal('PayerID');
     $details = $pp->GetExpressCheckoutDetails($token);
     $state = $details['SHIPTOSTATE'];
     // Calculate tax
     $tax = 0;
     $isTaxed = $taxRate->loadByZip($details['SHIPTOZIP']);
     if ($isTaxed == false) {
         $isTaxed = $taxRate->loadByState($state);
     }
     if ($isTaxed == false) {
         $isTaxed = $taxRate->loadByState('All Sales');
     }
     if ($isTaxed) {
         $taxable = Cart66Session::get('Cart66Cart')->getTaxableAmount($taxRate->tax_shipping);
         $tax = number_format($taxable * ($taxRate->rate / 100), 2, '.', '');
         if ($tax == 0) {
             $tax = Cart66Session::get('Cart66Cart')->getTax('All Sales');
         }
     }
 }
 ?>
 public function getTax($state = 'All Sales', $zip = null)
 {
     $tax = 0;
     $taxRate = new Cart66TaxRate();
     $isTaxed = $taxRate->loadByZip($zip);
     if ($isTaxed == false) {
         $isTaxed = $taxRate->loadByState($state);
         if ($state == 'All Sales' && $isTaxed) {
             Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] so i guess it's all sales? rate: " . $taxRate->rate);
             Cart66Session::set('Cart66TaxRate', Cart66Common::tax($taxRate->rate));
         }
     }
     if ($isTaxed) {
         $taxable = $this->getTaxableAmount($taxRate->tax_shipping);
         $tax = number_format($taxable * ($taxRate->rate / 100), 2, '.', '');
     }
     return $tax;
 }