本文整理汇总了PHP中Customer::getAddressesTotalById方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::getAddressesTotalById方法的具体用法?PHP Customer::getAddressesTotalById怎么用?PHP Customer::getAddressesTotalById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::getAddressesTotalById方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayOrderStep
function displayOrderStep($params)
{
global $smarty, $cookie, $cart, $order_pages_hook_position, $order_pages_hook_titles;
if (!Customer::getAddressesTotalById(intval($cookie->id_customer))) {
Tools::redirect('address.php?back=order.php?step=1');
}
$customer = new Customer(intval($cookie->id_customer));
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses(intval($cookie->id_lang));
$smarty->assign('addresses', $customerAddresses);
/* Setting default addresses for cart */
if ((!isset($cart->id_address_delivery) or empty($cart->id_address_delivery)) and sizeof($customerAddresses)) {
$cart->id_address_delivery = intval($customerAddresses[0]['id_address']);
$update = 1;
}
if ((!isset($cart->id_address_invoice) or empty($cart->id_address_invoice)) and sizeof($customerAddresses)) {
$cart->id_address_invoice = intval($customerAddresses[0]['id_address']);
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset($cart->id_address_delivery)) {
$deliveryAddress = new Address(intval($cart->id_address_delivery));
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset($cart->id_address_invoice)) {
$invoiceAddress = new Address(intval($cart->id_address_invoice));
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
$smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId(intval($cart->id))) {
$smarty->assign('oldMessage', $oldMessage['message']);
}
$smarty->assign('cart', $cart);
$smarty->assign('back', strval(Tools::getValue('back')));
Tools::safePostVars();
include_once dirname(__FILE__) . '/../../header.php';
echo $this->display(__FILE__, 'orderaddress.tpl');
}
示例2: str_replace
<?php
$useSSL = true;
$root_dir = str_replace('modules/veritranspay', '', dirname($_SERVER['SCRIPT_FILENAME']));
include_once $root_dir . '/config/config.inc.php';
include_once $root_dir . '/header.php';
include_once $root_dir . '/modules/veritranspay/veritranspay.php';
if (!$cookie->isLogged(true)) {
Tools::redirect('authentication.php?back=order.php');
} elseif (!Customer::getAddressesTotalById((int) $cookie->id_customer)) {
Tools::redirect('address.php?back=order.php?step=1');
}
$veritranspay = new VeritransPay();
echo $veritranspay->execPayment($cart);
include_once $root_dir . '/footer.php';
示例3: _assignAddress
protected function _assignAddress()
{
//if guest checkout disabled and flag is_guest in cookies is actived
if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 && (int) $this->context->customer->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
$this->context->customer->logout();
Tools::redirect('');
} else {
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
Tools::redirect('index.php?controller=address&back=' . urlencode('order.php?step=1&multi-shipping=' . (int) Tools::getValue('multi-shipping')));
}
}
$customer = $this->context->customer;
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses($this->context->language->id);
// Getting a list of formated address fields with associated values
$formatedAddressFieldsValuesList = array();
foreach ($customerAddresses as $i => $address) {
if (!Address::isCountryActiveById((int) $address['id_address'])) {
unset($customerAddresses[$i]);
}
$tmpAddress = new Address($address['id_address']);
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
unset($tmpAddress);
}
if (key($customerAddresses) != 0) {
$customerAddresses = array_values($customerAddresses);
}
if (!count($customerAddresses)) {
$bad_delivery = false;
if (($bad_delivery = (bool) (!Address::isCountryActiveById((int) $this->context->cart->id_address_delivery))) || !Address::isCountryActiveById((int) $this->context->cart->id_address_invoice)) {
$back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, array('step' => Tools::getValue('step'), 'multi-shipping' => (int) Tools::getValue('multi-shipping')));
$params = array('multi-shipping' => (int) Tools::getValue('multi-shipping'), 'id_address' => $bad_delivery ? (int) $this->context->cart->id_address_delivery : (int) $this->context->cart->id_address_invoice, 'back' => $back_url);
Tools::redirect($this->context->link->getPageLink('address', true, (int) $this->context->language->id, $params));
}
}
$this->context->smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
/* Setting default addresses for cart */
if ((!isset($this->context->cart->id_address_delivery) || empty($this->context->cart->id_address_delivery)) && count($customerAddresses)) {
$this->context->cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset($this->context->cart->id_address_invoice) || empty($this->context->cart->id_address_invoice)) && count($customerAddresses)) {
$this->context->cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) && $update) {
$this->context->cart->update();
// Address has changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart($this->context);
CartRule::autoAddToCart($this->context);
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset($this->context->cart->id_address_delivery)) {
$deliveryAddress = new Address((int) $this->context->cart->id_address_delivery);
if (Validate::isLoadedObject($deliveryAddress) && $deliveryAddress->id_customer == $customer->id) {
$this->context->smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset($this->context->cart->id_address_invoice)) {
$invoiceAddress = new Address((int) $this->context->cart->id_address_invoice);
if (Validate::isLoadedObject($invoiceAddress) && $invoiceAddress->id_customer == $customer->id) {
$this->context->smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId((int) $this->context->cart->id)) {
$this->context->smarty->assign('oldMessage', $oldMessage['message']);
}
}
示例4: preProcess
public function preProcess()
{
parent::preProcess();
if ($this->nbProducts) {
self::$smarty->assign('virtual_cart', false);
}
$this->isLogged = (bool) ((int) self::$cookie->id_customer and Customer::customerIdExistsStatic((int) self::$cookie->id_customer));
if (self::$cart->nbProducts()) {
if (Tools::isSubmit('ajax')) {
if (Tools::isSubmit('method')) {
switch (Tools::getValue('method')) {
case 'updateMessage':
if (Tools::isSubmit('message')) {
$txtMessage = urldecode(Tools::getValue('message'));
$this->_updateMessage($txtMessage);
if (sizeof($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
die(true);
}
break;
case 'updateCarrierAndGetPayments':
if (Tools::isSubmit('id_carrier') and Tools::isSubmit('recyclable') and Tools::isSubmit('gift') and Tools::isSubmit('gift_message')) {
if ($this->_processCarrier()) {
$return = array('summary' => self::$cart->getSummaryDetails(), 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods());
die(Tools::jsonEncode($return));
} else {
$this->errors[] = Tools::displayError('Error occurred updating cart.');
}
if (sizeof($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
exit;
}
break;
case 'updateTOSStatusAndGetPayments':
if (Tools::isSubmit('checked')) {
self::$cookie->checkedTOS = (int) Tools::getValue('checked');
die(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods())));
}
break;
case 'getCarrierList':
die(Tools::jsonEncode($this->_getCarrierList()));
break;
case 'editCustomer':
if (!$this->isLogged) {
exit;
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Tools::getValue('years')) {
$customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
}
$_POST['lastname'] = $_POST['customer_lastname'];
$_POST['firstname'] = $_POST['customer_firstname'];
$this->errors = $customer->validateControler();
$customer->newsletter = (int) Tools::isSubmit('newsletter');
$customer->optin = (int) Tools::isSubmit('optin');
$return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) self::$cookie->id_customer, 'token' => Tools::getToken(false));
if (!sizeof($this->errors)) {
$return['isSaved'] = (bool) $customer->update();
} else {
$return['isSaved'] = false;
}
die(Tools::jsonEncode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if (self::$cookie->isLogged()) {
// check if customer have addresses
if (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$blockUserInfo = new BlockUserInfo();
}
self::$smarty->assign('isVirtualCart', self::$cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
// Wrapping fees
$wrapping_fees = (double) Configuration::get('PS_GIFT_WRAPPING_PRICE');
$wrapping_fees_tax = new Tax((int) Configuration::get('PS_GIFT_WRAPPING_TAX'));
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (double) $wrapping_fees_tax->rate / 100);
$return = array('summary' => self::$cart->getSummaryDetails(), 'order_opc_adress' => self::$smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : '', 'carrier_list' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) self::$cookie->id_currency))));
die(Tools::jsonEncode($return));
}
die(Tools::displayError());
break;
case 'makeFreeOrder':
/* Bypass payment step if total is 0 */
if ($id_order = $this->_checkFreeOrder() and $id_order) {
$email = self::$cookie->email;
if (self::$cookie->is_guest) {
self::$cookie->logout();
}
// If guest we clear the cookie for security reason
die('freeorder:' . $id_order . ':' . $email);
}
exit;
break;
case 'updateAddressesSelected':
//.........这里部分代码省略.........
示例5: hookdisplayAdminCustomers
public function hookdisplayAdminCustomers($params)
{
if (!$this->active) {
return;
}
$xAux0 = Configuration::get('EKO_SMS_OP');
$xAux1 = Configuration::get('EKO_SMS_USERNAME');
$xAux2 = Configuration::get('EKO_SMS_PASSWORD');
if (empty($xAux0) or empty($xAux1) or empty($xAux2)) {
$this->smarty->assign(array('status' => 2, 'callfrom' => 2, 'SMSerror' => $this->l('SMS Module not Configured!')));
} else {
$customer = new Customer($params['id_customer']);
if (!$customer->isBanned($params['id_customer']) and $customer->getAddressesTotalById($params['id_customer']) > 0) {
$this->smarty->assign(array('status' => 1, 'callfrom' => 2, 'id_customer' => $params['id_customer'], 'id_order' => 0, 'pathSMS' => tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/ajax' . $this->name . '.php'));
} else {
$this->smarty->assign(array('status' => 2, 'callfrom' => 2, 'SMSerror' => $this->l('This user can not receive SMS!')));
}
}
return $this->display(__FILE__, '/sms.tpl');
}
示例6: init
/**
* Initialize order opc controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
if ($this->nbProducts) {
$this->context->smarty->assign('virtual_cart', $this->context->cart->isVirtualCart());
}
$this->context->smarty->assign('is_multi_address_delivery', $this->context->cart->isMultiAddressDelivery() || (int) Tools::getValue('multi-shipping') == 1);
$this->context->smarty->assign('open_multishipping_fancybox', (int) Tools::getValue('multi-shipping') == 1);
if ($this->context->cart->nbProducts()) {
if (Tools::isSubmit('ajax')) {
if (Tools::isSubmit('method')) {
switch (Tools::getValue('method')) {
case 'updateMessage':
if (Tools::isSubmit('message')) {
$txtMessage = urldecode(Tools::getValue('message'));
$this->_updateMessage($txtMessage);
if (count($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
die(true);
}
break;
case 'updateCarrierAndGetPayments':
if ((Tools::isSubmit('delivery_option') || Tools::isSubmit('id_carrier')) && Tools::isSubmit('recyclable') && Tools::isSubmit('gift') && Tools::isSubmit('gift_message')) {
$this->_assignWrappingAndTOS();
if ($this->_processCarrier()) {
$carriers = $this->context->cart->simulateCarriersOutput();
$return = array_merge(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'carrier_data' => $this->_getCarrierList(), 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers))), $this->getFormatedSummaryDetail());
Cart::addExtraCarriers($return);
die(Tools::jsonEncode($return));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the cart.');
}
if (count($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
exit;
}
break;
case 'updateTOSStatusAndGetPayments':
if (Tools::isSubmit('checked')) {
$this->context->cookie->checkedTOS = (int) Tools::getValue('checked');
die(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods())));
}
break;
case 'getCarrierList':
die(Tools::jsonEncode($this->_getCarrierList()));
break;
case 'editCustomer':
if (!$this->isLogged) {
exit;
}
if (Tools::getValue('years')) {
$this->context->customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
}
$_POST['lastname'] = $_POST['customer_lastname'];
$_POST['firstname'] = $_POST['customer_firstname'];
$this->errors = $this->context->customer->validateController();
$this->context->customer->newsletter = (int) Tools::isSubmit('newsletter');
$this->context->customer->optin = (int) Tools::isSubmit('optin');
$return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) $this->context->customer->id, 'token' => Tools::getToken(false));
if (!count($this->errors)) {
$return['isSaved'] = (bool) $this->context->customer->update();
} else {
$return['isSaved'] = false;
}
die(Tools::jsonEncode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if ($this->context->customer->isLogged()) {
// check if customer have addresses
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$blockUserInfo = new BlockUserInfo();
}
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
if (!($formatedAddressFieldsValuesList = $this->context->smarty->getTemplateVars('formatedAddressFieldsValuesList'))) {
$formatedAddressFieldsValuesList = array();
}
// Wrapping fees
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
$return = array_merge(array('order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($blockUserInfo) ? $blockUserInfo->hookDisplayTop(array()) : '', 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList, 'carrier_data' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) $this->context->cookie->id_currency)))), $this->getFormatedSummaryDetail());
die(Tools::jsonEncode($return));
}
die(Tools::displayError());
break;
case 'makeFreeOrder':
/* Bypass payment step if total is 0 */
if (($id_order = $this->_checkFreeOrder()) && $id_order) {
$order = new Order((int) $id_order);
//.........这里部分代码省略.........
示例7: _processGroupRules
/**
* Traitement des règles
* @param Customer $customer
*/
protected function _processGroupRules(Customer $customer)
{
//Inclusion de la classe des règles
include_once _PS_MODULE_DIR_ . '/customerautogroups/classes/AutoGroupRule.php';
//Nombres d'adresses du client
$customer_addresses = Customer::getAddressesTotalById($customer->id);
//Si le client n'a pas d'adresse on ne peut pas traiter les règles liées aux données d'adresses.
if (!$customer_addresses) {
$sqlCond = ' AND condition_type = 1 ';
} else {
$sqlCond = '';
}
//Récupération des règles applicables au client
$rules = Db::getInstance()->ExecuteS("SELECT * FROM " . _DB_PREFIX_ . "autogroup_rule WHERE active=1 " . $sqlCond . " ORDER BY priority");
$customerGroups = array();
foreach ($rules as $rule) {
//Traitement des règles de type "Client"
if ($rule['condition_type'] == AutoGroupRule::RULE_TYPE_CUSTOMER) {
$obj = $customer;
} else {
if ($rule['condition_type'] == AutoGroupRule::RULE_TYPE_ADDRESS) {
//Normalement vu que le client vient d'être créé il ne peut avoir qu'une adresse
$id_address = Db::getInstance()->getValue("SELECT id_address FROM " . _DB_PREFIX_ . "address WHERE id_customer=" . $customer->id);
$obj = new Address($id_address);
} else {
//echo $this->l('Error : rule type unknow');
continue;
}
}
//Il faut que la propriété de l'objet existe
if (!property_exists($obj, $rule['condition_field'])) {
//echo sprintf($this->l('Error : Unknow proprerty %s for class %'), $rule['condition_field'], get_class($obj));
continue;
}
//On teste la conditon
$ruleApplied = false;
$defaultGroup = false;
$cleanGroups = false;
switch ($rule['condition_operator']) {
case 'eq':
if ($obj->{$rule['condition_field']} == $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'ne':
if ($obj->{$rule['condition_field']} != $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'gt':
if ($obj->{$rule['condition_field']} > $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'ge':
if ($obj->{$rule['condition_field']} >= $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'lt':
if ($obj->{$rule['condition_field']} < $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'le':
if ($obj->{$rule['condition_field']} <= $rule['condition_value']) {
$ruleApplied = true;
}
break;
case 'LIKE %':
if (preg_match('#' . $rule['condition_value'] . '#', $obj->{$rule['condition_field']})) {
$ruleApplied = true;
}
break;
}
if ($ruleApplied) {
//echo sprintf( $this->l('Rule %d applied for customer'),$rule['id_rule']).'<br />';
$customerGroups[] = $rule['id_group'];
//Si la règle doit être la dernière à être traitée, on sors de la boucle
if ($rule['stop_processing'] == 1) {
if ($rule['default_group'] == 1) {
$defaultGroup = $rule['id_group'];
}
if ($rule['clean_groups'] == 1) {
$cleanGroups = true;
}
break;
}
}
}
//Ajout du client aux groupes nécessaires
if (sizeof($customerGroups)) {
//Si le flag de suppression des groupes
if ($cleanGroups) {
$customer->cleanGroups();
}
//.........这里部分代码省略.........
示例8: _assignAddress
protected function _assignAddress()
{
if (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
Tools::redirect('address.php?back=order.php?step=1');
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses((int) self::$cookie->id_lang);
self::$smarty->assign('addresses', $customerAddresses);
/* Setting default addresses for cart */
if ((!isset(self::$cart->id_address_delivery) or empty(self::$cart->id_address_delivery)) and sizeof($customerAddresses)) {
self::$cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset(self::$cart->id_address_invoice) or empty(self::$cart->id_address_invoice)) and sizeof($customerAddresses)) {
self::$cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
self::$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_delivery)) {
$deliveryAddress = new Address((int) self::$cart->id_address_delivery);
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
self::$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_invoice)) {
$invoiceAddress = new Address((int) self::$cart->id_address_invoice);
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
self::$smarty->assign('invoice', $invoiceAddress);
}
}
}
if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
self::$smarty->assign('oldMessage', $oldMessage['message']);
}
}
示例9: init
//.........这里部分代码省略.........
break;
case 'getCarrierList':
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$result = $this->_getCarrierList();
$result = array_merge($result, array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods()), $this->getFormatedSummaryDetail());
die(Tools::jsonEncode($result));
break;
case 'editCustomer':
if (!$this->isLogged) {
exit;
}
if (Tools::getValue('years')) {
$this->context->customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
}
if (trim(Tools::getValue('customer_lastname')) == "") {
$_POST['customer_lastname'] = $this->inv_first_on ? Tools::getValue('lastname_invoice') : Tools::getValue('lastname');
}
if (trim(Tools::getValue('customer_firstname')) == "") {
$_POST['customer_firstname'] = $this->inv_first_on ? Tools::getValue('firstname_invoice') : Tools::getValue('firstname');
}
$this->errors = $this->context->customer->validateController();
$this->context->customer->newsletter = (int) Tools::isSubmit('newsletter');
$this->context->customer->optin = (int) Tools::isSubmit('optin');
$return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) $this->context->customer->id, 'token' => Tools::getToken(false));
if (!count($this->errors)) {
$return['isSaved'] = (bool) $this->context->customer->update();
} else {
$return['isSaved'] = false;
}
die(Tools::jsonEncode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if ($this->context->customer->isLogged()) {
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$blockUserInfo = new BlockUserInfo();
}
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$customer = $this->context->customer;
$customer_info = array("id" => $customer->id, "email" => $customer->email, "id_gender" => $customer->id_gender, "birthday" => $customer->birthday, "newsletter" => $customer->newsletter, "optin" => $customer->optin, "is_guest" => $customer->is_guest);
$this->_processAddressFormat();
$this->_assignAddress();
$address_delivery = $this->context->smarty->tpl_vars['delivery']->value;
$address_invoice = $this->context->smarty->tpl_vars['invoice']->value;
if (Configuration::get('VATNUMBER_MANAGEMENT') && file_exists(_PS_MODULE_DIR_ . '/vatnumber/vatnumber.php') && !class_exists("VatNumber", false)) {
include_once _PS_MODULE_DIR_ . '/vatnumber/vatnumber.php';
}
if (isset($address_delivery) && Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && VatNumber::isApplicable($address_delivery->id_country) && Configuration::get('VATNUMBER_COUNTRY') != $address_delivery->id_country) {
$allow_eu_vat_delivery = 1;
} else {
$allow_eu_vat_delivery = 0;
}
if (isset($address_invoice) && Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && VatNumber::isApplicable($address_invoice->id_country) && Configuration::get('VATNUMBER_COUNTRY') != $address_invoice->id_country) {
$allow_eu_vat_invoice = 1;
} else {
$allow_eu_vat_invoice = 0;
}
$wrapping_fees_tax = new Tax((int) Configuration::get('PS_GIFT_WRAPPING_TAX'));
if (version_compare(_PS_VERSION_, "1.5.2.0") <= 0) {
$wrapping_fees = (double) Configuration::get('PS_GIFT_WRAPPING_PRICE');
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (double) $wrapping_fees_tax->rate / 100);
} else {
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
示例10: init
//.........这里部分代码省略.........
}
$this->context->customer->newsletter = (int) Tools::isSubmit('newsletter');
$this->context->customer->optin = (int) Tools::isSubmit('optin');
// foreach($this->errors as $key=> $value){
// // if($key=="lastname")$key="customer_lastname";
// // if($key=="firstname")$key="customer_firstname";
// $this->val_errors[$key]=$value;
// }
$return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) $this->context->customer->id, 'token' => Tools::getToken(false));
if (!count($this->errors)) {
$url = 'http://api.unisender.com/ru/api/subscribe?format=json&api_key=58priw95sdjt7umw17ixbnkkkudtoq5u7nmfcacy&list_ids=4734062';
$url .= '&fields[email]=' . trim($_POST['email']);
$url .= '&fields[Name]=' . urlencode($_POST['firstname'] . ' ' . $_POST['lastname']);
$url .= '&fields[phone]=' . trim($_POST['phone']);
$url .= '&tags=dev_etagerca';
$url .= '&double_optin=3';
$curl = curl_init($url);
curl_setopt_array($curl, array(CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true));
$result = json_decode(curl_exec($curl), true);
// var_dump($url);var_dump($result);exit();
if ($result['result'] && $result['result']['person_id']) {
setcookie('subscribe', '1', time() + 31536000);
$_COOKIE['subscribe'] = '1';
}
$return['isSaved'] = (bool) $this->context->customer->update();
} else {
$return['isSaved'] = false;
}
die(Tools::jsonEncode($return));
break;
case 'getAddressBlockAndCarriersAndPayments':
if ($this->isLogged) {
// check if customer have addresses
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$blockUserInfo = new BlockUserInfo();
}
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
if (!($formatedAddressFieldsValuesList = $this->context->smarty->getTemplateVars('formatedAddressFieldsValuesList'))) {
$formatedAddressFieldsValuesList = array();
}
// Wrapping fees
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
$return = array_merge(array('order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($blockUserInfo) ? $blockUserInfo->hookDisplayTop(array()) : '', 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList, 'carrier_data' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) $this->context->cookie->id_currency)))), $this->getFormatedSummaryDetail());
die(Tools::jsonEncode($return));
}
die(Tools::displayError());
break;
case 'makeFreeOrder':
/* Bypass payment step if total is 0 */
if (($id_order = $this->_checkFreeOrder()) && $id_order) {
$order = new Order((int) $id_order);
$email = $this->context->customer->email;
if ($this->context->customer->is_guest) {
$this->context->customer->logout();
}
// If guest we clear the cookie for security reason
die('freeorder:' . $order->reference . ':' . $email);
}
exit;
示例11: setContentProfile
/**
* Assign user profile data
* @param null
* @return null
*/
public function setContentProfile()
{
$sup = new SocialUserProfileModel();
$this->context->smarty->assign('customer', $sup->loadCustomerData($this->context->cookie->id_customer));
$this->context->smarty->assign('days', Tools::dateDays());
$this->context->smarty->assign('months', Tools::dateMonths());
$this->context->smarty->assign('years', Tools::dateYears());
$no_address = (int) Customer::getAddressesTotalById($this->context->cookie->id_customer);
if ($no_address != 0) {
$this->_address = $sup->loadAdressesData($this->context->cookie->id_customer, $sup->getAddressesByCustomerId($this->context->cookie->id_customer), $this->id_lang);
$this->assignCountries();
}
$this->context->smarty->assign('address', $this->_address[0]);
$this->context->smarty->assign('address_validation', Address::$definition['fields']);
}
示例12: _assignAddress
protected function _assignAddress()
{
//if guest checkout disabled and flag is_guest in cookies is actived
if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 and (int) self::$cookie->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
self::$cookie->logout();
Tools::redirect('');
} elseif (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
//Tools::redirect('address.php?back=order.php?step=1');
//self::$smarty->assign('no_address', 1);
}
$customer = new Customer((int) self::$cookie->id_customer);
if (Validate::isLoadedObject($customer)) {
/* Getting customer addresses */
$customerAddresses = $customer->getAddresses((int) self::$cookie->id_lang);
// Getting a list of formated address fields with associated values
$formatedAddressFieldsValuesList = array();
foreach ($customerAddresses as $address) {
$tmpAddress = new Address($address['id_address']);
$formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
$formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
unset($tmpAddress);
}
self::$smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
/* Setting default addresses for cart */
if ((!isset(self::$cart->id_address_delivery) or empty(self::$cart->id_address_delivery)) and sizeof($customerAddresses)) {
self::$cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
if ((!isset(self::$cart->id_address_invoice) or empty(self::$cart->id_address_invoice)) and sizeof($customerAddresses)) {
self::$cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
$update = 1;
}
/* Update cart addresses only if needed */
if (isset($update) and $update) {
self::$cart->update();
}
/* If delivery address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_delivery)) {
$deliveryAddress = new Address((int) self::$cart->id_address_delivery);
if ($deliveryAddress->id_state) {
$deliveryAddress->state = State::getNameById($deliveryAddress->id_state);
}
if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
self::$smarty->assign('delivery', $deliveryAddress);
}
}
/* If invoice address is valid in cart, assign it to Smarty */
if (isset(self::$cart->id_address_invoice)) {
$invoiceAddress = new Address((int) self::$cart->id_address_invoice);
if ($invoiceAddress->id_state) {
$invoiceAddress->state = State::getNameById($invoiceAddress->id_state);
}
if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
self::$smarty->assign('invoice', $invoiceAddress);
}
}
//assign countries
$countries = Country::getCountries(1);
$country_names = Country::getActiveCountries();
self::$smarty->assign('countries', $countries);
self::$smarty->assign('country_names', $country_names);
if (isset(self::$cookie->id_country)) {
$id_current_country = self::$cookie->id_country;
} else {
$id_current_country = Tools::getValue('id_country', (int) $customer->id_country);
}
self::$smarty->assign('current_country', $id_current_country);
//default to USA
if (!$id_current_country) {
$id_current_country = 21;
}
//assign states
$country = new Country($id_current_country);
if ($country->contains_states) {
$stateData = State::getStatesByIdCountry($customer->id_country);
self::$smarty->assign('states', $stateData);
}
}
if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
self::$smarty->assign('oldMessage', $oldMessage['message']);
}
//Assign token for new address
self::$smarty->assign('token', Tools::getToken(false));
self::$smarty->assign('id_carrier', self::$cart->id_carrier);
}
示例13: init
//.........这里部分代码省略.........
if (count($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
die(true);
}
break;
case 'updateCarrierAndGetPayments':
if ((Tools::isSubmit('delivery_option') || Tools::isSubmit('id_carrier')) && Tools::isSubmit('recyclable') && Tools::isSubmit('gift') && Tools::isSubmit('gift_message')) {
$this->_assignWrappingAndTOS();
if ($this->_processCarrier()) {
$carriers = $this->context->cart->simulateCarriersOutput();
$return = array_merge(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'carrier_data' => $this->_getCarrierList(), 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers))), $this->getFormatedSummaryDetail());
Cart::addExtraCarriers($return);
die(Tools::jsonEncode($return));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the cart.');
}
if (count($this->errors)) {
die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
}
exit;
}
break;
case 'updateTOSStatusAndGetPayments':
if (Tools::isSubmit('checked')) {
$this->context->cookie->checkedTOS = (int) Tools::getValue('checked');
die(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods())));
}
break;
case 'getCarrierList':
die(Tools::jsonEncode($this->_getCarrierList()));
case 'getAddressBlockAndCarriersAndPayments':
if ($this->context->customer->isLogged()) {
if (!Customer::getAddressesTotalById($this->context->customer->id)) {
die(Tools::jsonEncode(array('no_address' => 1)));
}
if (file_exists(_PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php')) {
include_once _PS_MODULE_DIR_ . 'blockuserinfo/blockuserinfo.php';
$block_user_info = new BlockUserInfo();
}
$this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
$this->_processAddressFormat();
$this->_assignAddress();
$wrapping_fees = $this->context->cart->getGiftWrappingPrice(false);
$wrapping_fees_tax_inc = $wrapping_fees = $this->context->cart->getGiftWrappingPrice();
$return = array_merge(array('order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_ . 'order-address.tpl'), 'block_user_info' => isset($block_user_info) ? $block_user_info->hookTop(array()) : '', 'carrier_data' => $this->_getCarrierList(), 'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'no_address' => 0, 'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int) $this->context->cookie->id_currency)))), $this->getFormatedSummaryDetail());
die(Tools::jsonEncode($return));
}
die(Tools::displayError());
case 'makeFreeOrder':
if (($id_order = $this->_checkFreeOrder()) && $id_order) {
$order = new Order((int) $id_order);
$email = $this->context->customer->email;
if ($this->context->customer->is_guest) {
$this->context->customer->logout();
}
die('freeorder:' . $order->reference . ':' . $email);
}
exit;
case 'updateAddressesSelected':
$get_order_reference_details_request = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
$get_order_reference_details_request->setSellerId(self::$amz_payments->merchant_id);
$get_order_reference_details_request->setAmazonOrderReferenceId(Tools::getValue('amazonOrderReferenceId'));
if (isset($this->context->cookie->amz_access_token)) {
$get_order_reference_details_request->setAddressConsentToken(AmzPayments::prepareCookieValueForAmazonPaymentsUse($this->context->cookie->amz_access_token));
}