/** * Get Zone Id by Address Id */ public function getZoneIdByAddress($address_id) { if (!is_numeric($address_id)) { return false; } require_once 'models/client/client_address.php'; $Address = new client_address(); $address = $Address->getDetail($address_id); return $this->getZoneIdByCountry($address['country_id']); }
/** * get client data * * @param integer $id * client ID * * @return array * customer informations */ function getClientData($id = 0) { if (!is_numeric($id)) { msg('client_customer->getClientData: Id is not numeric', 'error'); return false; } // basic info $client['customer'] = $this->getDetail($id); // address details require_once 'models/client/client_address.php'; $Address = new client_address(); if (is_numeric($client['customer']['delivery_address_id']) && $client['customer']['delivery_address_id'] > 0) { $client['address']['delivery'] = $Address->getDetail($client['customer']['delivery_address_id']); } if (is_numeric($client['customer']['invoices_address_id']) && $client['customer']['invoices_address_id'] > 0) { $client['address']['invoices'] = $Address->getDetail($client['customer']['invoices_address_id']); } // company details if ($client['customer']['company_id'] > 0) { require_once 'models/client/client_company.php'; $Company = new client_company(); $client['company'] = $Company->detail($client['customer']['company_id']); } return $client; }
/** * main action */ public function mainAction() { /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); $this->tpl->assign('NODE_CONF', $node_conf); /** * client */ require_once 'models/client/client_address.php'; $Address = new client_address(); if (is_numeric($this->GET['invoices_address_id'])) { $invoices_address_id = $this->GET['invoices_address_id']; } if (is_numeric($this->GET['delivery_address_id'])) { $delivery_address_id = $this->GET['delivery_address_id']; } //if we have not address_ids, we'll use session data if (!is_numeric($invoices_address_id) && !is_numeric($delivery_address_id)) { $invoices_address_id = $_SESSION['client']['customer']['invoices_address_id']; $delivery_address_id = $_SESSION['client']['customer']['delivery_address_id']; } if (is_numeric($invoices_address_id)) { $invoices = $Address->getDetail($invoices_address_id); } else { $invoices = false; } if (is_numeric($delivery_address_id)) { $delivery = $Address->getDetail($delivery_address_id); } else { $delivery = false; } $addr['invoices'] = $invoices; $addr['delivery'] = $delivery; $this->tpl->assign('ADDRESS', $addr); if (is_array($addr['invoices'])) { if ($addr['invoices']['line_2'] != '') { $this->tpl->parse('content.invoices.line_2'); } if ($addr['invoices']['line_3'] != '') { $this->tpl->parse('content.invoices.line_3'); } if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.invoices.button'); } $this->tpl->parse('content.invoices'); } else { if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.invoices_add_button'); } } if (is_array($addr['delivery'])) { if ($addr['delivery']['line_2'] != '') { $this->tpl->parse('content.delivery.line_2'); } if ($addr['delivery']['line_3'] != '') { $this->tpl->parse('content.delivery.line_3'); } if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.delivery.button'); } $this->tpl->parse('content.delivery'); } else { if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.delivery_add_button'); } } return true; }
/** * Return true if given address and customer is VAT eligible * * @param int $delivery_address_id Delivery address id to check EU status * @param int $customer_id Customer id to check whole sale status (not implemented yet!) * @return boolean */ function isVatEligible($delivery_address_id, $customer_id) { $order_conf = ecommerce_order::initConfiguration(); require_once 'models/client/client_address.php'; $Address = new client_address(); $delivery = $Address->getDetail($delivery_address_id); $exclude_vat = $order_conf['non_eu_zero_vat'] && !$delivery['country']['eu_status']; return !$exclude_vat; }
/** * main action */ public function mainAction() { /** * include node configuration */ require_once 'models/common/common_node.php'; $node_conf = common_node::initConfiguration(); /** * client */ require_once 'models/client/client_address.php'; $Address = new client_address(); if (is_numeric($this->GET['invoices_address_id'])) { $invoices_address_id = $this->GET['invoices_address_id']; } if (is_numeric($this->GET['delivery_address_id'])) { $delivery_address_id = $this->GET['delivery_address_id']; } // is guest checkout required? $guest_checkout = $_SESSION['client']['customer']['guest']; // address edit link if ($guest_checkout) { $this->tpl->assign('UPDATE_PAGE_ID', $node_conf['id_map-guest_registration']); } else { $this->tpl->assign('UPDATE_PAGE_ID', $node_conf['id_map-checkout_delivery_options']); } //if we have not address_ids, we'll use session data if (!is_numeric($invoices_address_id) && !is_numeric($delivery_address_id)) { $invoices_address_id = $_SESSION['client']['customer']['invoices_address_id']; $delivery_address_id = $_SESSION['client']['customer']['delivery_address_id']; } if (is_numeric($invoices_address_id)) { $invoices = $Address->getDetail($invoices_address_id); } else { if ($guest_checkout) { $invoices = $_SESSION['client']['address']['invoices']; $invoices['country']['name'] = $this->getCountryName($invoices['country_id']); } else { $invoices = false; } } if (is_numeric($delivery_address_id)) { $delivery = $Address->getDetail($delivery_address_id); } else { if ($guest_checkout) { $delivery = $_SESSION['client']['address']['delivery']; $delivery['country']['name'] = $this->getCountryName($delivery['country_id']); } else { $delivery = false; } } $addr['invoices'] = $invoices; $addr['delivery'] = $delivery; $this->tpl->assign('ADDRESS', $addr); if (is_array($addr['invoices'])) { if ($addr['invoices']['line_2'] != '') { $this->tpl->parse('content.invoices.line_2'); } if ($addr['invoices']['line_3'] != '') { $this->tpl->parse('content.invoices.line_3'); } if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.invoices.button'); } $this->tpl->parse('content.invoices'); } if (is_array($addr['delivery'])) { if ($addr['delivery']['line_2'] != '') { $this->tpl->parse('content.delivery.line_2'); } if ($addr['delivery']['line_3'] != '') { $this->tpl->parse('content.delivery.line_3'); } if ($this->GET['hide_button'] == 0) { $this->tpl->parse('content.delivery.button'); } $this->tpl->parse('content.delivery'); } return true; }