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; }
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); }