当前位置: 首页>>代码示例>>PHP>>正文


PHP Address::add方法代码示例

本文整理汇总了PHP中Address::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::add方法的具体用法?PHP Address::add怎么用?PHP Address::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayMain

 public function displayMain()
 {
     global $smarty, $link, $cookie;
     $errors = false;
     if (!$cookie->logged || !User::checkPassword($cookie->id_user, $cookie->passwd)) {
         Tools::redirect($link->getPage('userView'));
     }
     $referer = Tools::Q('referer') ? $link->getPage(Tools::Q('referer')) : $link->getPage('MyAddressesView');
     if ($id_address = Tools::Q('id')) {
         $address = new Address((int) $id_address);
         if (Tools::isSubmit('saveAddress')) {
             $address->copyFromPost();
             if ($address->update()) {
                 Tools::redirect($referer);
             } else {
                 $errors = $address->_errors;
             }
         }
         $smarty->assign('address', $address);
     } elseif (Tools::isSubmit('saveAddress')) {
         $address = new Address();
         $address->copyFromPost();
         $address->id_user = $cookie->id_user;
         if ($address->add()) {
             Tools::redirect($referer);
         } else {
             $errors = $address->_errors;
         }
     }
     $countrys = Country::loadData(1, 1000, 'position', 'asc', array('active' => true));
     $smarty->assign(array('referer' => Tools::Q('referer'), 'countrys' => $countrys, 'errors' => $errors));
     return $smarty->fetch('address.tpl');
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:33,代码来源:AddressView.php

示例2: init

 public function init()
 {
     parent::init();
     if (Tools::isSubmit('storedelivery') && (int) Tools::getValue('storedelivery') != 0) {
         //Save cookie only if previous id_adress wasn't a store
         $cookie = new Cookie('storedelivery');
         $cookie->__set('id_address_delivery', $this->context->cart->id_address_delivery);
         $store = new Store(Tools::getValue('storedelivery'));
         //Test if store address exist in address table
         Tools::strlen($store->name) > 32 ? $storeName = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($storeName = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
         $sql = 'SELECT id_address FROM ' . _DB_PREFIX_ . 'address WHERE alias=\'' . addslashes($storeName) . '\' AND address1=\'' . addslashes($store->address1) . '\' AND address2=\'' . addslashes($store->address2) . '\' AND postcode=\'' . $store->postcode . '\' AND city=\'' . addslashes($store->city) . '\' AND id_country=\'' . addslashes($store->id_country) . '\' AND active=1 AND deleted=0';
         $id_address = Db::getInstance()->getValue($sql);
         //Create store adress if not exist for this user
         if (empty($id_address)) {
             $country = new Country($store->id_country, $this->context->language->id);
             $address = new Address();
             $address->id_country = $store->id_country;
             $address->id_state = $store->id_state;
             $address->country = $country->name;
             Tools::strlen($store->name) > 32 ? $address->alias = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->alias = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             Tools::strlen($store->name) > 32 ? $address->lastname = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->lastname = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             $address->firstname = " ";
             $address->address1 = $store->address1;
             $address->address2 = $store->address2;
             $address->postcode = $store->postcode;
             $address->city = $store->city;
             $address->phone = $store->phone;
             $address->deleted = 0;
             //create an address non deleted to register them in order
             $address->add();
             $id_address = $address->id;
         }
         //Update cart info
         $cart = $this->context->cart;
         $cart->id_address_delivery = $id_address;
         $cart->update();
         //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
         Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $id_address), $where = 'id_cart = ' . $this->context->cart->id);
         //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
         $array = array_values(Tools::getValue('delivery_option'));
         $_POST['delivery_option'] = array($id_address => $array[0]);
     } else {
         $cookie = new Cookie('storedelivery');
         $id_address_delivery = $cookie->__get('id_address_delivery');
         if ($id_address_delivery != false && $this->context->cart->id_address_delivery != $id_address_delivery && Tools::isSubmit('storedelivery')) {
             $this->context->cart->id_address_delivery = $cookie->__get('id_address_delivery');
             $this->context->cart->update();
             //Change address of all product in cart else we are redirect on step Carrier because of function autostep or OrderController
             Db::getInstance()->update('cart_product', array('id_address_delivery' => (int) $cookie->__get('id_address_delivery')), $where = 'id_cart = ' . $this->context->cart->id);
             //Change post carrier option else bad default carrier is saved by fonction processCarrier of ParentOrderController
             $array = array_values(Tools::getValue('delivery_option'));
             $_POST['delivery_option'] = array($cookie->__get('id_address_delivery') => $array[0]);
             $cookie->__unset('id_address_delivery');
         }
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:56,代码来源:OrderController.php

示例3: displayMain

 public function displayMain()
 {
     global $smarty, $link;
     $errors = array();
     if (Tools::isSubmit('CreateUser')) {
         if (!Validate::isEmail(Tools::getRequest('email')) || User::userExists(Tools::getRequest('email'))) {
             $errors[] = 'The email is invalid or an account is already registered with this e-mail!';
         } elseif (empty($_POST['passwd'])) {
             $errors[] = 'The password is empty!';
         } else {
             $user = new User();
             $user->copyFromPost();
             $user->active = 1;
             if ($user->add()) {
                 $address = new Address();
                 $address->copyFromPost();
                 $address->id_user = $user->id;
                 $address->is_default = 1;
                 if ($address->add()) {
                     $user->logined(array('id_address' => $address->id));
                     if (Tools::getRequest("step") == 2) {
                         Tools::redirect($link->getPage('CheckoutView'));
                     } else {
                         Tools::redirect($link->getPage('MyaccountView'));
                     }
                     return;
                 } else {
                     $errors = $address->_errors;
                 }
             } else {
                 $errors = $user->_errors;
             }
         }
     }
     $countrys = Country::loadData(1, 500, null, null, array('active' => 1));
     $smarty->assign(array('id_default_country' => Configuration::get('TM_DEFAULT_COUNTRY_ID'), 'countrys' => $countrys, 'step' => Tools::getRequest("step"), 'errors' => $errors));
     return $smarty->fetch('join.tpl');
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:38,代码来源:JoinView.php

示例4: getShippingAddressID

 function getShippingAddressID($id_country, $id_state)
 {
     if (!$id_state) {
         $id_state = 0;
     }
     $sql = 'SELECT id_address FROM  `' . _DB_PREFIX_ . 'address` WHERE alias=\'agileexpress\' AND id_customer=0 AND id_manufacturer=0 AND id_supplier=0 AND id_country=' . $id_country . ' AND id_state=' . $id_state;
     $result = Db::getInstance()->getRow($sql);
     $id_address = 0;
     $id_address = isset($result['id_address']) ? intval($result['id_address']) : 0;
     if ($id_address <= 0) {
         $address = new Address();
         $address->id = 0;
         $address->alias = 'agileexpress';
         $address->id_customer = 0;
         $address->id_manufacturer = 0;
         $address->id_supplier = 0;
         $address->id_country = $id_country;
         $address->id_state = $id_state;
         $address->lastname = 'Temporary';
         $address->firstname = 'Address';
         $address->address1 = 'For shipping fee and tax calculation only';
         $address->address2 = 'It will be replaced with real address';
         $address->city = ' after payment';
         $address->postcode = 'postcode';
         $address->add();
         $id_address = $address->id;
     }
     return $id_address;
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:29,代码来源:agilepaypalbase.php

示例5: hookAjaxOpc

 public function hookAjaxOpc()
 {
     $cookie = new Cookie('storedelivery');
     $cookie->__set('id_address_delivery', $this->context->cart->id_address_delivery);
     $cookie->__set('opc', true);
     if (Tools::isSubmit('storedelivery') && (int) Tools::getValue('storedelivery') != 0) {
         $store = new Store(Tools::getValue('storedelivery'));
         //Test if store address exist in address table
         Tools::strlen($store->name) > 32 ? $storeName = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($storeName = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
         $sql = 'SELECT id_address FROM ' . _DB_PREFIX_ . 'address WHERE alias=\'' . addslashes($storeName) . '\' AND address1=\'' . addslashes($store->address1) . '\' AND address2=\'' . addslashes($store->address2) . '\' AND postcode=\'' . $store->postcode . '\' AND city=\'' . addslashes($store->city) . '\' AND id_country=\'' . addslashes($store->id_country) . '\' AND active=1 AND deleted=0';
         $id_address = Db::getInstance()->getValue($sql);
         //Create store adress if not exist for this user
         if (empty($id_address)) {
             $country = new Country($store->id_country, $this->context->language->id);
             $address = new Address();
             $address->id_country = $store->id_country;
             $address->id_state = $store->id_state;
             $address->country = $country->name;
             Tools::strlen($store->name) > 32 ? $address->alias = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->alias = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             Tools::strlen($store->name) > 32 ? $address->lastname = Tools::substr(preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name), 0, 29) . '...' : ($address->lastname = preg_replace("/[^a-zA-Zěščřžýáíéèêàô ]+/", '', $store->name));
             $address->firstname = $this->l('Store of');
             $address->address1 = $store->address1;
             $address->address2 = $store->address2;
             $address->postcode = $store->postcode;
             $address->city = $store->city;
             $address->phone = $store->phone;
             $address->deleted = 0;
             //create an address non deleted to register them in order
             $address->add();
             $id_address = $address->id;
         }
         $cookie->__set('id_address_delivery', $id_address);
     }
     die(Tools::jsonEncode(array('result' => "ok")));
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:35,代码来源:storedelivery.php

示例6: ajaxProcessSaveOrder

    public function ajaxProcessSaveOrder()
    {
        $products = Tools::getValue('products');
        $delivery_date = Tools::getValue('delivery_date');
        $delivery_time_from = Tools::getValue('delivery_time_from');
        $delivery_time_to = Tools::getValue('delivery_time_to');
        $id_employee = Tools::getValue('employees');
        if (!empty($id_employee) && is_array($id_employee)) {
            $id_employee = $id_employee[0];
        }
        $other = Tools::getValue('other');
        if (empty($products)) {
            PrestaShopLogger::addLog('AphCalendar::saveOrder - Products to be select', 1, null, 'AphCalendar', 0, true);
            die(Tools::jsonEncode(array('result' => false, 'error' => 'Non e\' stato selezionato nessun prodotto. Prego selezionarle almeno uno.')));
        }
        $id_customer = (int) Tools::getValue('id_customer');
        if ($id_customer < 1) {
            $customer = new Customer();
            $customer->firstname = Tools::getValue('firstname');
            $customer->lastname = Tools::getValue('lastname');
            $customer->email = Tools::getValue('email');
            $customer->phone = Tools::getValue('phone');
            $customer->id_gender = Tools::getValue('id_gender');
            $customer->id_shop = (int) Context::getContext()->shop->id;
            $customer->passwd = strtoupper(Tools::passwdGen(10));
            $customer->newsletter = 1;
            if ($customer->validateFields(false, true) !== true) {
                PrestaShopLogger::addLog('AphCalendar::saveOrder - Fields of customer not valid', 1, null, 'AphCalendar', 0, true);
                die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione del cliente. Prego riprovare.')));
            }
            $result = $customer->add();
            if (!$result) {
                PrestaShopLogger::addLog('AphCalendar::saveOrder - Address of customer is to be added', 1, null, 'AphCalendar', 0, true);
                die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione del cliente. Prego riprovare.')));
            }
            $stores = Db::getInstance()->executeS('
			SELECT st.id_country,st.id_state,st.city
			FROM ' . _DB_PREFIX_ . 'store_shop ss
			LEFT JOIN `' . _DB_PREFIX_ . 'store` st 
				ON (ss.`id_store` = st.`id_store`)
			WHERE ss.`id_shop` = ' . (int) Context::getContext()->shop->id);
            $address = new Address();
            $address->id_customer = $customer->id;
            $address->alias = 'indirizzo';
            $address->firstname = $customer->firstname;
            $address->lastname = $customer->lastname;
            $address->address1 = '-';
            $address->postcode = '00000';
            $address->phone = $customer->phone;
            $address->phone_mobile = $customer->phone;
            $address->id_country = $stores[0]['id_country'];
            $address->id_state = $stores[0]['id_state'];
            $address->city = $stores[0]['city'];
            if ($address->validateFields(false, true) !== true) {
                PrestaShopLogger::addLog('AphCalendar::saveOrder - Fields of address of customer not valid', 1, null, 'AphCalendar', 0, true);
                die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione del cliente. Prego riprovare.')));
            }
            $address->add();
            $customer->id_address_delivery = $address->id;
            $customer->id_address_invoice = $address->id;
            if (!$result) {
                PrestaShopLogger::addLog('AphCalendar::saveOrder - Customer is to be added', 1, null, 'AphCalendar', 0, true);
                die(Tools::jsonEncode(array('result' => false, 'error' => 'Si e\' verificato un problema durante la creazione del cliente. Prego riprovare.')));
            }
            $id_customer = $customer->id;
        } else {
            $customer = new Customer($id_customer);
            $customer->firstname = Tools::getValue('firstname');
            $customer->lastname = Tools::getValue('lastname');
            $customer->email = Tools::getValue('email');
            $customer->phone = Tools::getValue('phone');
            $customer->id_gender = Tools::getValue('id_gender');
            $customer->id_shop = (int) Context::getContext()->shop->id;
            $customer->update();
            $addresses = $customer->getAddresses((int) Context::getContext()->language->id);
            if (empty($addresses)) {
                $customer->id_address_delivery = $customer->id_address_invoice = 0;
            } else {
                $customer->id_address_delivery = $addresses[0]['id_address'];
                $customer->id_address_invoice = $addresses[0]['id_address'];
                $address = new Address($addresses[0]['id_address'], (int) Context::getContext()->language->id);
                $address->firstname = $customer->firstname;
                $address->lastname = $customer->lastname;
                $address->phone = $customer->phone;
                $address->phone_mobile = $customer->phone;
                $address->update();
            }
        }
        $id_order = (int) Tools::getValue('id_order');
        $feature_duration = Configuration::get('APH_FEATURE_DURATION');
        $services_duration = json_decode(Configuration::get('APH_SERVICES_DURATION'), true);
        $reservation_offline_status = Configuration::get('APH_RESERVATION_OFFLINE_STATUS');
        // always add taxes even if there are not displayed to the customer
        $use_taxes = true;
        // Total method
        $total_method = Cart::BOTH_WITHOUT_SHIPPING;
        //TODO ajaxProcessAddProductOnOrder() in AdminOrdersController
        if ($id_order < 1) {
            do {
                $reference = Order::generateReference();
//.........这里部分代码省略.........
开发者ID:paolobattistella,项目名称:aphro,代码行数:101,代码来源:AdminAphCalendarController.php

示例7: addAddress

 /**
  * Create virtual address to associate id_zone for a country selection
  *
  * @param $id_country
  * @param $zipcode
  * @return bool
  */
 private function addAddress($id_country, $zipcode)
 {
     $customer = new Customer((int) Configuration::get(CarrierCompare::VIRTUAL_CUSTOMER));
     $address = new Address();
     $address->id_country = $id_country;
     $address->alias = 'Shipping Estimation';
     $address->lastname = $customer->lastname;
     $address->firstname = $customer->firstname;
     $address->address1 = 'test';
     $address->city = 'test';
     $address->postcode = $zipcode;
     $address->id_customer = $customer->id;
     if ($address->add()) {
         Configuration::updateValue(CarrierCompare::VIRTUAL_ADDRESS, $address->id);
         return true;
     }
     return false;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:25,代码来源:carriercompare.php

示例8: getPSAddress

 protected function getPSAddress(Customer $customer, ShopgateAddress $shopgateAddress)
 {
     // Get country
     $id_country = Country::getByIso($shopgateAddress->getCountry());
     if (!$id_country) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_UNKNOWN_COUNTRY_CODE, 'Invalid country code:' . $id_country, true);
     }
     // Get state
     $id_state = 0;
     if ($shopgateAddress->getState()) {
         $id_state = (int) Db::getInstance()->getValue('SELECT `id_state` FROM `' . _DB_PREFIX_ . 'state` WHERE `id_country` = ' . $id_country . ' AND `iso_code` = \'' . pSQL(Tools::substr($shopgateAddress->getState(), 3, 2)) . '\'');
     }
     // Create alias
     $alias = Tools::substr('Shopgate_' . $customer->id . '_' . sha1($customer->id . '-' . $shopgateAddress->getFirstName() . '-' . $shopgateAddress->getLastName() . '-' . $shopgateAddress->getCompany() . '-' . $shopgateAddress->getStreet1() . '-' . $shopgateAddress->getStreet2() . '-' . $shopgateAddress->getZipcode() . '-' . $shopgateAddress->getCity()), 0, 32);
     // Try getting address id by alias
     $id_address = Db::getInstance()->getValue('SELECT `id_address` FROM `' . _DB_PREFIX_ . 'address` WHERE `alias` = \'' . pSQL($alias) . '\' AND `id_customer`=' . $customer->id);
     // Get or create address
     $address = new Address($id_address ? $id_address : null);
     if (!$address->id) {
         $address->id_customer = $customer->id;
         $address->id_country = $id_country;
         $address->id_state = $id_state;
         $address->country = Country::getNameById($this->id_lang, $address->id_country);
         $address->alias = $alias;
         $address->company = $shopgateAddress->getCompany();
         $address->lastname = $shopgateAddress->getLastName();
         $address->firstname = $shopgateAddress->getFirstName();
         $address->address1 = $shopgateAddress->getStreet1();
         $address->address2 = $shopgateAddress->getStreet2();
         $address->postcode = $shopgateAddress->getZipcode();
         $address->city = $shopgateAddress->getCity();
         $address->phone = $shopgateAddress->getPhone();
         $address->phone_mobile = $shopgateAddress->getMobile();
         if (!$address->add()) {
             throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DATABASE_ERROR, 'Unable to create address', true);
         }
     }
     return $address;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:39,代码来源:PSShopgatePlugin.php

示例9: submitAccount

function submitAccount()
{
    global $cookie, $errors, $smarty;
    $email = Tools::getValue('email');
    if (empty($email) or !Validate::isEmail($email)) {
        $errors[] = Tools::displayError('e-mail not valid');
    } elseif (!Validate::isPasswd(Tools::getValue('passwd'))) {
        $errors[] = Tools::displayError('invalid password');
    } elseif (Customer::customerExists($email)) {
        $errors[] = Tools::displayError('someone has already registered with this e-mail address');
    } elseif (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
        $errors[] = Tools::displayError('invalid birthday');
    } else {
        $customer = new Customer();
        if (Tools::isSubmit('newsletter')) {
            $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
            $customer->newsletter_date_add = pSQL(date('Y-m-d h:i:s'));
        }
        $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
        /* Customer and address, same fields, caching data */
        $errors = $customer->validateControler();
        $address = new Address();
        $address->id_customer = 1;
        $errors = array_unique(array_merge($errors, $address->validateControler()));
        if (!sizeof($errors)) {
            $customer->active = 1;
            if (!$customer->add()) {
                $errors[] = Tools::displayError('an error occurred while creating your account');
            } else {
                $address->id_customer = (int) $customer->id;
                if (!$address->add()) {
                    $errors[] = Tools::displayError('an error occurred while creating your address');
                } else {
                    if (Mail::Send((int) $cookie->id_lang, 'account', Mail::l('Welcome!', (int) $cookie->id_lang), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                        $smarty->assign('confirmation', 1);
                    }
                    $cookie->id_customer = (int) $customer->id;
                    $cookie->customer_lastname = $customer->lastname;
                    $cookie->customer_firstname = $customer->firstname;
                    $cookie->passwd = $customer->passwd;
                    $cookie->logged = 1;
                    $cookie->email = $customer->email;
                    Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                    // Next !
                    $payerID = strval(Tools::getValue('payerID'));
                    displayProcess($payerID);
                }
            }
        }
    }
}
开发者ID:greench,项目名称:prestashop,代码行数:51,代码来源:submit.php

示例10: newAddress

 /**
  * make new address of PILIBABA WAREHOUSE assign to customer
  *
  * @param Order ,
  *
  * @return id, The address id which inserted into database;
  **/
 protected function newAddress($order)
 {
     $pilibbabAddress = PilipayWarehouseAddress::getWarehouseAddressBy(Tools::getValue(self::PILIPAY_WAREHOUSES, Configuration::get(self::PILIPAY_WAREHOUSES)));
     $AddressObject = new Address();
     $AddressObject->id_customer = $order->id_customer;
     $AddressObject->firstname = pSQL($pilibbabAddress['firstName']);
     $AddressObject->lastname = pSQL($pilibbabAddress['lastName']);
     $AddressObject->address1 = pSQL($pilibbabAddress['address']);
     $AddressObject->city = pSQL($pilibbabAddress['city']);
     $AddressObject->id_country = pSQL(PilipayWarehouseAddress::getCountryId());
     $AddressObject->id_state = pSQL(PilipayWarehouseAddress::getStateId());
     $AddressObject->phone = pSQL($pilibbabAddress['tel']);
     $AddressObject->postcode = pSQL($pilibbabAddress['zipcode']);
     $AddressObject->alias = 'pilibaba';
     $AddressObject->add();
     return $AddressObject->id;
 }
开发者ID:pilibaba,项目名称:pilipay-for-prestashop,代码行数:24,代码来源:pilipay.php

示例11: saveAddress

 private function saveAddress($cart_id_address, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $address1)
 {
     $dummy = "dummyvalue";
     if ($cart_id_address > 0) {
         // update existing one
         $tmp_addr = new Address($cart_id_address);
         $tmp_addr->deleted = 0;
     } else {
         // create a new address
         $tmp_addr = new Address();
         $tmp_addr->alias = "My Address";
         $tmp_addr->lastname = $dummy;
         $tmp_addr->firstname = $dummy;
         $tmp_addr->address1 = $dummy;
         $tmp_addr->postcode = $postcode;
         $tmp_addr->city = $dummy;
     }
     if (trim($postcode) != "") {
         $tmp_addr->postcode = $postcode;
     }
     if (trim($city) != "") {
         $tmp_addr->city = $city;
     }
     if (trim($firstname) != "") {
         $tmp_addr->firstname = $firstname;
     }
     if (trim($lastname) != "") {
         $tmp_addr->lastname = $lastname;
     }
     if (trim($address1) != "") {
         $tmp_addr->address1 = $address1;
     }
     if (trim($id_country) == "") {
         $id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     }
     if (trim($id_country) != "") {
         $tmp_addr->id_country = $id_country;
         if (trim($id_state) != "") {
             $tmp_addr->id_state = $id_state;
         } else {
             $tmp_addr->id_state = 0;
         }
         if (Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && !VatNumber::isApplicable($id_country)) {
             $tmp_addr->vat_number = "";
         }
         if ($cart_id_address > 0) {
             $tmp_addr->update();
         } else {
             $tmp_addr->add();
         }
         return $tmp_addr->id;
     } else {
         return 0;
     }
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:55,代码来源:AddressController.php

示例12: saveAddress

 private function saveAddress($cart_id_address, $id_country, $id_state, $postcode, $city, $firstname, $lastname, $address1)
 {
     $dummy = "dummyvalue";
     if ($cart_id_address > 0) {
         // update existing one
         /* @var $tmp_addr AddressCore */
         $tmp_addr = new Address($cart_id_address);
         $tmp_addr->deleted = 0;
     } else {
         // create a new address
         $tmp_addr = new Address();
         $tmp_addr->alias = "My Address";
         $tmp_addr->lastname = $dummy;
         $tmp_addr->firstname = $dummy;
         $tmp_addr->address1 = $dummy;
         $tmp_addr->postcode = $postcode;
         $tmp_addr->city = $dummy;
     }
     if (trim($postcode) != "") {
         $tmp_addr->postcode = $postcode;
     }
     // For carrier module which depend on city field
     if (trim($city) != "") {
         $tmp_addr->city = $city;
     }
     if (trim($firstname) != "") {
         $tmp_addr->firstname = $firstname;
     }
     if (trim($lastname) != "") {
         $tmp_addr->lastname = $lastname;
     }
     if (trim($address1) != "") {
         $tmp_addr->address1 = $address1;
     }
     // kvoli virtual produktom, ked online country bola skryta a teda id_country bolo prazdne
     if (trim($id_country) == "") {
         $id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     }
     if (trim($id_country) != "") {
         $tmp_addr->id_country = $id_country;
         if (trim($id_state) != "") {
             $tmp_addr->id_state = $id_state;
         } else {
             $tmp_addr->id_state = 0;
         }
         // Reset VAT number when address is non-EU (otherwise, taxes won't be added when VAT address changes to non-VAT!)
         if (Configuration::get('VATNUMBER_MANAGEMENT') and file_exists(dirname(__FILE__) . '/../../modules/vatnumber/vatnumber.php') && !VatNumber::isApplicable($id_country)) {
             $tmp_addr->vat_number = "";
         }
         if ($cart_id_address > 0) {
             $tmp_addr->update();
         } else {
             $tmp_addr->add();
             // $opckt_helper->addAddressIdAndCartId($tmp_addr->id, $this->context->cookie->id_cart);
         }
         return $tmp_addr->id;
     } else {
         return 0;
     }
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:60,代码来源:AddressController.php

示例13: update_cart_by_junglee_xml

    public function update_cart_by_junglee_xml($order_id, $orderdetail)
    {
        $prefix = _DB_PREFIX_;
        $tablename = $prefix . 'orders';
        $total_amount = 0;
        $total_principal = 0;
        $shipping_amount = 0;
        $total_promo = 0;
        $ClientRequestId = 0;
        $AmazonOrderID = (string) $orderdetail->OrderReport->AmazonOrderID;
        foreach ($orderdetail->OrderReport->Item as $item) {
            $SKU = (string) $item->SKU;
            $Title = (string) $item->Title;
            $Quantity = (int) $item->Quantity;
            $Principal_Promotions = 0;
            $Shipping_Promotions = 0;
            foreach ($item->ItemPrice->Component as $amount_type) {
                $item_charge_type = (string) $amount_type->Type;
                if ($item_charge_type == 'Principal') {
                    $Principal = abs((double) $amount_type->Amount);
                }
                if ($item_charge_type == 'Shipping') {
                    $Shipping = abs((double) $amount_type->Amount);
                }
                if ($item_charge_type == 'Tax') {
                    $Tax = abs((double) $amount_type->Amount);
                }
                if ($item_charge_type == 'ShippingTax') {
                    $ShippingTax = abs((double) $amount_type->Amount);
                }
            }
            if (!empty($item->Promotion)) {
                foreach ($item->Promotion as $promotions) {
                    foreach ($promotions->Component as $promotion_amount_type) {
                        $promotion_type = (string) $promotion_amount_type->Type;
                        if ($promotion_type == 'Shipping') {
                            $Shipping_Promotions += abs((double) $promotion_amount_type->Amount);
                        }
                        if ($promotion_type == 'Principal') {
                            $Principal_Promotions += abs((double) $promotion_amount_type->Amount);
                        }
                    }
                }
            }
            $total_principal += $Principal;
            $total_amount += $Principal - $Principal_Promotions + ($Shipping - $Shipping_Promotions);
            $shipping_amount += $Shipping + $Shipping_Promotions;
            $total_promo += $Principal_Promotions + $Shipping_Promotions;
            foreach ($item->CustomizationInfo as $info) {
                $info_type = (string) $info->Type;
                if ($info_type == 'url') {
                    $info_array = explode(',', $info->Data);
                    $customerId_array = explode('=', $info_array[0]);
                    $ClientRequestId = $customerId_array[1];
                }
            }
        }
        $ShippingServiceLevel = (string) $orderdetail->OrderReport->FulfillmentData->FulfillmentServiceLevel;
        $sql = 'UPDATE `' . $prefix . 'pwa_orders` set `shipping_service` = "' . $ShippingServiceLevel . '" , `order_type` = "junglee" where `prestashop_order_id` = "' . $order_id . '" ';
        Db::getInstance()->Execute($sql);
        $cust_name = (string) $orderdetail->OrderReport->BillingData->BuyerName;
        $name_arr = explode(' ', $cust_name);
        if (count($name_arr) > 1) {
            $firstname = '';
            for ($i = 0; $i < count($name_arr) - 2; $i++) {
                $firstname = $firstname . ' ' . $name_arr[$i];
            }
            $lastname = $name_arr[count($name_arr) - 1];
        } else {
            $firstname = $cust_name;
            $lastname = ' ';
        }
        $email = (string) $orderdetail->OrderReport->BillingData->BuyerEmailAddress;
        $sql = 'SELECT * from `' . $prefix . 'customer` where email = "' . $email . '" ';
        $results = Db::getInstance()->ExecuteS($sql);
        if (empty($results)) {
            $password = Tools::passwdGen();
            $customer = new Customer();
            $customer->firstname = trim($firstname);
            $customer->lastname = $lastname;
            $customer->email = (string) $xml->ProcessedOrder->BuyerInfo->BuyerEmailAddress;
            $customer->passwd = md5($password);
            $customer->active = 1;
            if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
                $customer->is_guest = 1;
            } else {
                $customer->is_guest = 0;
            }
            $customer->add();
            $customer_id = $customer->id;
            if (Configuration::get('PS_CUSTOMER_CREATION_EMAIL') && !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
                Mail::Send($this->context->language->id, 'account', Mail::l('Welcome!'), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => $password), $customer->email, $customer->firstname . ' ' . $customer->lastname);
            }
        } else {
            $customer_id = $results[0]['id_customer'];
        }
        $id_country = Country::getByIso((string) $orderdetail->OrderReport->FulfillmentData->Address->CountryCode);
        if ($id_country == 0 || $id_country == '') {
            $id_country = 110;
        }
//.........这里部分代码省略.........
开发者ID:ankkal,项目名称:SPN_project,代码行数:101,代码来源:GetReportRequestList.php

示例14: isSameAddress

 public function isSameAddress($idAddress, $idCart, $idCustomer)
 {
     $sql = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'country WHERE iso_code = "BE"');
     $isoBel = $sql['id_country'];
     $sql = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'country WHERE iso_code = "FR"');
     $isoFr = $sql['id_country'];
     $return = Db::getInstance()->GetRow('SELECT * FROM ' . _DB_PREFIX_ . 'socolissimo_delivery_info WHERE id_cart =\'' . intval($idCart) . '\' AND id_customer =\'' . intval($idCustomer) . '\'');
     $psAddress = new Address(intval($idAddress));
     $newAddress = new Address();
     // in 1.7.0 country is mandatory
     if ($return['cecountry'] == "FR") {
         $isoCode = $isoFr;
         $nameCountry = "france";
     }
     if ($return['cecountry'] == "BE") {
         $nameCountry = "belgique";
         $isoCode = $isoBel;
     }
     if ($this->upper($psAddress->lastname) != $this->upper($return['prname']) || $this->upper($psAddress->firstname) != $this->upper($return['prfirstname']) || $this->upper($psAddress->address1) != $this->upper($return['pradress3']) || $this->upper($psAddress->address2) != $this->upper($return['pradress2']) || $this->upper($psAddress->postcode) != $this->upper($return['przipcode']) || $this->upper($psAddress->city) != $this->upper($return['prtown']) || str_replace(array(' ', '.', '-', ',', ';', '+', '/', '\\', '+', '(', ')'), '', $psAddress->phone_mobile) != $return['cephonenumber']) {
         $newAddress->id_customer = intval($idCustomer);
         $newAddress->lastname = substr($return['prname'], 0, 32);
         $newAddress->firstname = substr($return['prfirstname'], 0, 32);
         $newAddress->postcode = $return['przipcode'];
         $newAddress->city = $return['prtown'];
         $newAddress->id_country = $isoCode;
         $newAddress->alias = 'So Colissimo - ' . date('d-m-Y');
         if (!in_array($return['delivery_mode'], array('DOM', 'RDV'))) {
             $newAddress->active = 1;
             $newAddress->deleted = 1;
             $newAddress->address1 = $return['pradress1'];
             $newAddress->add();
         } else {
             $newAddress->address1 = $return['pradress3'];
             isset($return['pradress2']) ? $newAddress->address2 = $return['pradress2'] : ($newAddress->address2 = '');
             isset($return['pradress1']) ? $newAddress->other .= $return['pradress1'] : ($newAddress->other = '');
             isset($return['pradress4']) ? $newAddress->other .= ' | ' . $return['pradress4'] : ($newAddress->other = '');
             $newAddress->postcode = $return['przipcode'];
             $newAddress->city = $return['prtown'];
             $newAddress->id_country = $isoCode;
             $newAddress->alias = 'So Colissimo - ' . date('d-m-Y');
             $newAddress->add();
         }
         return intval($newAddress->id);
     } else {
         return intval($psAddress->id);
     }
 }
开发者ID:quadra-informatique,项目名称:SoColissimo-1.x-PrestaShop,代码行数:47,代码来源:socolissimo.php

示例15: validation

    public function validation()
    {
        if (!$this->active || !Configuration::get('GOINTERPAY_STORE') || !Configuration::get('GOINTERPAY_SECRET')) {
            return false;
        }
        if (!isset($_GET['orderId'])) {
            return false;
        }
        include_once _PS_MODULE_DIR_ . 'gointerpay/Rest.php';
        $rest = new Rest(Configuration::get('GOINTERPAY_STORE'), Configuration::get('GOINTERPAY_SECRET'));
        $result = $rest->orderDetail(Tools::safeOutput(Tools::getValue('orderId')));
        $cart = new Cart((int) $result['cartId']);
        $original_total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
        /* Check the currency code */
        $id_currency_new = (int) Currency::getIdByIsoCode($result['foreignCurrencyCode']);
        if ($id_currency_new) {
            $cart->id_currency = (int) $id_currency_new;
            $cart->save();
        } else {
            die('Sorry, we were not able to accept orders in the following currency: ' . Tools::safeOutput($result['foreignCurrencyCode']));
        }
        $name = explode(" ", $result['delivery_address']['name']);
        $lastname = " - ";
        if (isset($name[1])) {
            $lastname = $name[1];
        }
        /* Update the delivery and billing address */
        $delivery_address = new Address((int) $cart->id_address_delivery);
        $delivery_address->firstname = $name[0];
        $delivery_address->lastname = $lastname;
        $delivery_address->company = $result['delivery_address']['company'];
        $delivery_address->phone = $result['delivery_address']['phone'];
        $delivery_address->phone_mobile = $result['delivery_address']['altPhone'];
        $delivery_address->id_country = (int) Country::getByIso($result['delivery_address']['countryCode']);
        $delivery_address->id_state = (int) State::getIdByIso($result['delivery_address']['state'], (int) $delivery_address->id_country);
        $delivery_address->address1 = $result['delivery_address']['address1'];
        $delivery_address->address2 = $result['delivery_address']['address2'];
        $delivery_address->city = $result['delivery_address']['city'];
        $delivery_address->postcode = $result['delivery_address']['zip'];
        $delivery_address->save();
        /* If no billing address specified, use the delivery address */
        if ($result['invoice_address']['address1'] != '' || $result['invoice_address']['city'] != '') {
            $invoice_name = explode(" ", $result['invoice_address']['name']);
            $invoice_lastname = " - ";
            if (isset($invoice_name[1])) {
                $invoice_lastname = $invoice_name[1];
            }
            $invoice_address = new Address((int) $cart->id_address_invoice);
            $invoice_address->firstname = $invoice_name[0];
            $invoice_address->lastname = $invoice_lastname;
            $invoice_address->company = $result['invoice_address']['company'];
            $invoice_address->phone = $result['invoice_address']['phone'];
            $invoice_address->phone_mobile = $result['invoice_address']['altPhone'];
            $invoice_address->id_country = (int) Country::getByIso($result['invoice_address']['countryCode']);
            $invoice_address->id_state = (int) State::getIdByIso($result['invoice_address']['state'], (int) $invoice_address->id_country);
            $invoice_address->address1 = $result['invoice_address']['address1'];
            $invoice_address->address2 = $result['invoice_address']['address2'];
            $invoice_address->city = $result['invoice_address']['city'];
            $invoice_address->postcode = $result['invoice_address']['zip'];
            if ($cart->id_address_delivery == $cart->id_address_invoice) {
                $invoice_address->add();
                $cart->id_address_invoice = (int) $invoice_address->id;
                $cart->save();
            } else {
                $invoice_address->save();
            }
        }
        /* Store the Order ID and Shipping cost */
        Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'gointerpay_order_id` (`id_cart`, `orderId`, `shipping`, `shipping_orig`, `taxes`, `total`, `products`, `status`)
		VALUES (\'' . (int) $cart->id . '\', \'' . pSQL(Tools::getValue('orderId')) . '\', \'' . (double) $result['shippingTotal'] . '\', \'' . (double) $result['shippingTotalForeign'] . '\', \'' . (double) $result['quotedDutyTaxes'] . '\', \'' . (double) $result['grandTotal'] . '\', \'' . (double) $result['itemsTotal'] . '\', \'Init\')');
        /* Add the duties and taxes */
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'specific_price` WHERE id_customer = ' . (int) $cart->id_customer . ' AND id_product = ' . (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
        $specific_price = new SpecificPrice();
        $specific_price->id_product = (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES');
        $specific_price->id_shop = 0;
        $specific_price->id_country = 0;
        $specific_price->id_group = 0;
        $specific_price->id_cart = (int) $cart->id;
        $specific_price->id_product_attribute = 0;
        $specific_price->id_currency = $cart->id_currency;
        $specific_price->id_customer = $cart->id_customer;
        $specific_price->price = (double) $result['quotedDutyTaxesForeign'];
        $specific_price->from_quantity = 1;
        $specific_price->reduction = 0;
        $specific_price->reduction_type = 'percentage';
        $specific_price->from = date('Y-m-d H:i:s');
        $specific_price->to = strftime('%Y-%m-%d %H:%M:%S', time() + 10);
        $specific_price->add();
        if (Validate::isLoadedObject($specific_price)) {
            $cart->updateQty(1, (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
        }
        $result['status'] = 'Pending';
        $total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
        $message = '
		Total paid on Interpay: ' . (double) $result['grandTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Duties and taxes on Interpay: ' . (double) $result['quotedDutyTaxesForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Shipping on Interpay: ' . (double) $result['shippingTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Currency: ' . $result['foreignCurrencyCode'];
        if ($result['status'] == 'Pending') {
            $this->context->cart->id = (int) $result['cartId'];
//.........这里部分代码省略.........
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:101,代码来源:gointerpay.php


注:本文中的Address::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。