示例#1
0
 public function save()
 {
     $data = $this->post();
     $count = count($data['tax_name']);
     $index = 0;
     $taxes = array();
     while ($count > $index) {
         if ($data['tax_name'][$index] == 'xyz' || $data['tax_name'][$index] == '' || $data['tax_country'][$index] == '' || $data['tax_rate'][$index] == 0) {
             $index++;
             continue;
         }
         $tax['name'] = $data['tax_name'][$index];
         $tax['country'] = $data['tax_country'][$index];
         $tax['region'] = $data['tax_region'][$index];
         $tax['rate'] = $data['tax_rate'][$index];
         $taxes[] = $tax;
         $index++;
     }
     // empty all taxes then add all taxes sent
     $taxObj = new TaxObject();
     $taxObj->deleteAll();
     foreach ($taxes as $tax) {
         $taxObj->add($tax);
     }
     $this->redirect('/dashboard/razor/tax');
 }
示例#2
0
 public function set_customer_location($country, $state)
 {
     // get taxes
     $taxClass = new Tax();
     $taxes = $taxClass->getByRegion($country, $state);
     $this->currentCart->applyTaxes($taxes);
     $this->currentCart->updateTotal();
     $order = $this->currentCart;
     $totals = array('subtotal' => $order->getSubtotal(), 'taxTotal' => $order->getTaxTotal(), 'shippingTotal' => $order->getShippingCost(), 'total' => $order->getTotal());
     $data = array('totals' => $totals, 'taxes' => $taxes);
     print json_encode($data);
     exit;
 }
示例#3
0
 public function view()
 {
     // get customer location
     $customer = new CustomerAccount();
     if (isset($customer->ui)) {
         $billing_address = $customer->ui->getAttribute('billing_address');
         $country = $billing_address->country;
         $state = $billing_address->state_province;
         // set tax
         $taxClass = new Tax();
         $taxes = $taxClass->getByRegion($country, $state);
         $this->currentCart->applyTaxes($taxes);
     }
     $this->currentCart->updateTotal();
     $this->set('cart', $this->currentCart);
 }