public function section_tax_settings() { $rate = new Cart66TaxRate(); $successMessage = ''; $errorMessage = ''; if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($_POST['cart66-action'] == 'save rate') { $data = $_POST['tax']; if (isset($data['state']) && empty($data['state']) && (isset($data['zip']) && empty($data['zip']))) { $errorMessage = __('You must choose a state or enter a Zipcode', 'cart66'); } elseif (isset($data['rate']) && empty($data['rate'])) { $errorMessage = __('Please provide a tax rate', 'cart66'); } else { if (isset($data['zip']) && !empty($data['zip'])) { $zipCodes = explode('-', $data['zip']); if (count($zipCodes) > 1) { list($low, $high) = $zipCodes; } if (isset($low)) { $low = trim($low); } else { $low = $data['zip']; } if (isset($high)) { $high = trim($high); } else { $high = $low; } if (is_numeric($low) && is_numeric($high)) { if ($low > $high) { $x = $high; $high = $low; $low = $x; } $data['zip_low'] = $low; $data['zip_high'] = $high; } } $rate->setData($data); $rate->save(); $rate->clear(); $successMessage = __("Tax rate saved", "cart66"); } } } elseif (isset($_GET['task']) && $_GET['task'] == 'deleteTax' && isset($_GET['id']) && $_GET['id'] > 0) { $id = Cart66Common::getVal('id'); $rate->load($id); $rate->deleteMe(); $rate->clear(); } $data = array('rate' => $rate, 'success_message' => $successMessage, 'error_message' => $errorMessage); echo Cart66Common::getView('admin/settings/tax.php', $data, false); }
<?php $settingsOk = true; $username = Cart66Setting::getValue('paypalpro_api_username'); $password = Cart66Setting::getValue('paypalpro_api_password'); $signature = Cart66Setting::getValue('paypalpro_api_signature'); if (!($username && $password && $signature)) { $settingsOk = false; throw new Cart66Exception('Invalid PayPal Express Configuration', 66501); } if ($_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['cart66-action']) && $_POST['cart66-action'] == 'paypalexpresscheckout') { // Set up the PayPal object $pp = new Cart66PayPalExpressCheckout(); $taxRate = new Cart66TaxRate(); // Calculate total amount to charge customer $total = Cart66Session::get('Cart66Cart')->getGrandTotal(false); $total = number_format($total, 2, '.', ''); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal Express Checkout grand total: {$total}"); // Calculate total cost of all items in cart, not including tax and shipping $itemTotal = Cart66Session::get('Cart66Cart')->getNonSubscriptionAmount(); $itemTotal = number_format($itemTotal, 2, '.', ''); Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] PayPal Express Checkout item total: {$itemTotal}"); // Calculate shipping costs $shipping = Cart66Session::get('Cart66Cart')->getShippingCost(); $promotion = Cart66Session::get('Cart66Promotion'); $discount = Cart66Session::get('Cart66Cart')->getDiscountAmount(); if (is_object($promotion) && $promotion->apply_to == 'total') { $itemTotal = Cart66Session::get('Cart66Cart')->getNonSubscriptionAmount(); $itemDiscount = Cart66Session::get('Cart66Cart')->getDiscountAmount(); if ($itemDiscount > 0) { $itemTotal = $itemTotal - $itemDiscount;
/** * 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')); } }
<?php $taxRate = new Cart66TaxRate(); $session_token = Cart66Session::get('PayPalProToken'); // Look for the Express Checkout token $token = Cart66Common::postVal('token'); if (empty($token)) { $token = Cart66Common::getVal('token'); } if ($session_token == $token) { $username = Cart66Setting::getValue('paypalpro_api_username'); $password = Cart66Setting::getValue('paypalpro_api_password'); $signature = Cart66Setting::getValue('paypalpro_api_signature'); // Get details about the buyer $pp = new Cart66PayPalExpressCheckout(); if (CART66_PRO) { $pp = new Cart66PayPalPro(); } $details = $pp->GetExpressCheckoutDetails($token); $account = false; if (Cart66Session::get('Cart66Cart')->hasSubscriptionProducts() || Cart66Session::get('Cart66Cart')->hasMembershipProducts()) { // Set up a new Cart66Account and start by pre-populating the data or load the logged in account if ($accountId = Cart66Common::isLoggedIn()) { $account = new Cart66Account($accountId); } else { $account = new Cart66Account(); $account->firstName = $details['FIRSTNAME']; $account->lastName = $details['LASTNAME']; $account->email = $details['EMAIL']; if (isset($_POST['account'])) { $acctData = $_POST['account'];
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; }