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


PHP Carrier::getPreferredCarriers方法代码示例

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


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

示例1: _addAddress

 protected function _addAddress($step)
 {
     $id_address = (int) Tools::getValue('id_address', 0);
     if ($id_address && !Tools::getValue('address_update', 0)) {
         $address = new Address((int) $id_address);
         if (Validate::isLoadedObject($address) and Customer::customerHasAddress((int) self::$cookie->id_customer, (int) $id_address)) {
             if (Tools::isSubmit('delete')) {
                 if (self::$cart->id_address_invoice == $address->id) {
                     unset(self::$cart->id_address_invoice);
                 }
                 if (self::$cart->id_address_delivery == $address->id) {
                     unset(self::$cart->id_address_delivery);
                 }
                 if ($address->delete()) {
                     Tools::redirect('order.php?step=1');
                 }
                 $this->errors[] = Tools::displayError('This address cannot be deleted.');
             }
             self::$smarty->assign(array('address' => $address, 'id_address' => (int) $id_address));
             if (Tools::isSubmit('id_state') and Tools::getValue('id_state') != NULL and is_numeric(Tools::getValue('id_state'))) {
                 $selected_state = Tools::getValue('id_state');
             } elseif (isset($address) and isset($address->id_state) and !empty($address->id_state) and isset($address->id_state)) {
                 $selected_state = $address->id_state;
             } else {
                 $selected_state = false;
             }
             // default to karnataka.
             if (Tools::isSubmit('id_country') and Tools::getValue('id_country') != NULL and is_numeric(Tools::getValue('id_country'))) {
                 $selected_country = Tools::getValue('id_country');
             } elseif (isset($address) and isset($address->id_country) and !empty($address->id_country) and isset($address->id_state)) {
                 $selected_country = $address->id_country;
             } else {
                 $selected_country = false;
             }
             self::$smarty->assign('selected_country', $selected_country);
             self::$smarty->assign('selected_state', $selected_state);
         }
     }
     if (Tools::isSubmit('submitAddress')) {
         $address = new Address();
         $this->errors = $address->validateControler();
         $address->id_customer = (int) self::$cookie->id_customer;
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('Please add your mobile phone number.');
         }
         if (!($country = new Country((int) $address->id_country)) or !Validate::isLoadedObject($country)) {
             die(Tools::displayError());
         }
         //remove zipcode verification
         /*
          $zip_code_format = $country->zip_code_format;
          if ($country->need_zip_code)
          {
          if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
          {
          $zip_regexp = '/^'.$zip_code_format.'$/ui';
          $zip_regexp = str_replace(' ', '( |)', $zip_regexp);
          $zip_regexp = str_replace('-', '(-|)', $zip_regexp);
          $zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
          $zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
          $zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
          if (!preg_match($zip_regexp, $postcode))
          $this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
          }
          elseif ($zip_code_format)
          $this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
          elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
          $this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
          }
         */
         if (!Tools::isSubmit('order_add_address_billing')) {
             //validate pincode and assign possible payment options
             $op = 0;
             $op = Carrier::getPreferredCarriers($country->id);
             if ($op == 0) {
                 $this->errors[] = 'We are sorry but we do not provide service to this region as of now. However, we keep adding new locations with time and would request you to check our website a few weeks later. We apologise for the inconvenience caused. ';
             }
         }
         if (!$country->isNeedDni()) {
             $address->dni = NULL;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and self::$cookie->isLogged(true) === true) {
             $this->errors[] = Tools::displayError('Invalid token');
         }
         if ((int) $country->contains_states and !(int) $address->id_state) {
             $this->errors[] = Tools::displayError('Please select a state.');
         }
         if (!sizeof($this->errors)) {
             if (isset($id_address)) {
                 $country = new Country((int) $address->id_country);
                 if (Validate::isLoadedObject($country) and !$country->contains_states) {
                     $address->id_state = 0;
                 }
                 $address_old = new Address((int) $id_address);
                 if (Validate::isLoadedObject($address_old) and Customer::customerHasAddress((int) self::$cookie->id_customer, (int) $address_old->id)) {
                     if ($address_old->isUsed()) {
                         $address_old->delete();
                         if (!Tools::isSubmit('ajax')) {
                             $to_update = false;
                             if (self::$cart->id_address_invoice == $address_old->id) {
//.........这里部分代码省略.........
开发者ID:priyankajsr19,项目名称:shalu,代码行数:101,代码来源:OrderController.php

示例2: viewDetails


//.........这里部分代码省略.........
     </fieldset>';
     /* Display shipping infos */
     echo '
     <fieldset style="width:400px">
         <legend><img src="../img/admin/delivery.gif" /> ' . $this->l('Shipping information') . '</legend>
         ' . $this->l('Total weight:') . ' <b>' . number_format($order->getTotalWeight(), 3) . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</b><br />
         ' . $this->l('Carrier:') . ' <b>' . ($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name) . '</b><br />
         ' . (($currentState->delivery or $order->delivery_number) ? '<br /><a href="pdf.php?id_delivery=' . $order->delivery_number . '">' . $this->l('Delivery slip #') . '<b>' . Configuration::get('PS_DELIVERY_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', $order->delivery_number) . '</b></a><br />' : '');
     if ($order->shipping_number) {
         echo $this->l('Tracking number:') . ' <b>' . $order->shipping_number . '</b> ' . (!empty($carrier->url) ? '(<a href="' . str_replace('@', $order->shipping_number, $carrier->url) . '" target="_blank">' . $this->l('Track the shipment') . '</a>)' : '');
     }
     /* Carrier module */
     if ($carrier->is_module == 1) {
         $module = Module::getInstanceByName($carrier->external_module_name);
         if (method_exists($module, 'displayInfoByCart')) {
             echo call_user_func(array($module, 'displayInfoByCart'), $order->id_cart);
         }
     }
     /* Display shipping number field */
     if ($carrier->url && $order->hasBeenShipped()) {
         echo '
             <form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="margin-top:10px;">
                 <input type="text" name="shipping_number" value="' . $order->shipping_number . '" />
                 <input type="hidden" name="id_order" value="' . $order->id . '" />
                 <input type="submit" name="submitShippingNumber" value="' . $this->l('Set shipping number') . '" class="button" />
             </form>';
     }
     /* Display carrier field */
     echo '
             <form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="margin-top:10px;">
                 <select name="id_carrier">';
     $carriers = array();
     $op = $cod = false;
     Carrier::getPreferredCarriers($addressDelivery->id_country, $carriers);
     $orderCarriers = false;
     if (strpos($order->payment, 'COD') === false) {
         $orderCarriers = $carriers['service'];
     } else {
         $orderCarriers = $carriers['cod'];
     }
     foreach ($orderCarriers as $cid) {
         if ($cid == UPS) {
             echo '<option value="' . UPS . '" ' . ($order->id_carrier == UPS ? 'selected="selected"' : '') . ' >UPS</option>';
         }
         if ($cid == ARAMEX) {
             echo '<option value="' . ARAMEX . '" ' . ($order->id_carrier == ARAMEX ? 'selected="selected"' : '') . ' >Aramex</option>';
         }
         if ($cid == FEDEX) {
             echo '<option value="' . FEDEX . '" ' . ($order->id_carrier == FEDEX ? 'selected="selected"' : '') . ' >Fedex</option>';
         }
         if ($cid == BLUEDART) {
             echo '<option value="' . BLUEDART . '" ' . ($order->id_carrier == BLUEDART ? 'selected="selected"' : '') . ' >BlueDart</option>';
         }
     }
     echo '
                 </select>
                 <input type="hidden" name="id_order" value="' . $order->id . '" />
                 <input type="submit" name="submitCarrier" value="' . $this->l('Set Carrier') . '" class="button" />
             </form>';
     echo '
     </fieldset>';
     /* Display summary order */
     echo '
     <br />
     <fieldset style="width: 400px">
         <legend><img src="../img/admin/details.gif" /> ' . $this->l('Order details') . '</legend>
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:67,代码来源:AdminOrders.php

示例3: preProcess

 public function preProcess()
 {
     parent::preProcess();
     if ($back = Tools::getValue('back')) {
         self::$smarty->assign('back', Tools::safeOutput($back));
     }
     if ($mod = Tools::getValue('mod')) {
         self::$smarty->assign('mod', Tools::safeOutput($mod));
     }
     if (Tools::isSubmit('ajax') and Tools::isSubmit('type')) {
         if (Tools::getValue('type') == 'delivery') {
             $id_address = isset(self::$cart->id_address_delivery) ? (int) self::$cart->id_address_delivery : 0;
         } elseif (Tools::getValue('type') == 'invoice') {
             $id_address = (isset(self::$cart->id_address_invoice) and self::$cart->id_address_invoice != self::$cart->id_address_delivery) ? (int) self::$cart->id_address_invoice : 0;
         } else {
             exit;
         }
     } else {
         $id_address = (int) Tools::getValue('id_address', 0);
     }
     if ($id_address) {
         $this->_address = new Address((int) $id_address);
         if (Validate::isLoadedObject($this->_address) and Customer::customerHasAddress((int) self::$cookie->id_customer, (int) $id_address)) {
             if (Tools::isSubmit('delete')) {
                 if (self::$cart->id_address_invoice == $this->_address->id) {
                     unset(self::$cart->id_address_invoice);
                 }
                 if (self::$cart->id_address_delivery == $this->_address->id) {
                     unset(self::$cart->id_address_delivery);
                 }
                 if ($this->_address->delete()) {
                     Tools::redirect('addresses.php');
                 }
                 $this->errors[] = Tools::displayError('This address cannot be deleted.');
             }
             self::$smarty->assign(array('address' => $this->_address, 'id_address' => (int) $id_address));
         } elseif (Tools::isSubmit('ajax')) {
             exit;
         } else {
             Tools::redirect('addresses.php');
         }
     }
     if (Tools::isSubmit('submitAddress')) {
         $address = new Address();
         $this->errors = $address->validateControler();
         $address->id_customer = (int) self::$cookie->id_customer;
         if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
             $this->errors[] = Tools::displayError('You must register at least one phone number');
         }
         if (!($country = new Country((int) $address->id_country)) or !Validate::isLoadedObject($country)) {
             die(Tools::displayError());
         }
         /* US customer: normalize the address */
         if ($address->id_country == Country::getByIso('US')) {
             include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
             $normalize = new AddressStandardizationSolution();
             $address->address1 = $normalize->AddressLineStandardization($address->address1);
             $address->address2 = $normalize->AddressLineStandardization($address->address2);
         }
         //remove zipcode verification
         /*
         $zip_code_format = $country->zip_code_format;
         if ($country->need_zip_code)
         {
         	if (($postcode = Tools::getValue('postcode')) AND $zip_code_format)
         	{
         		$zip_regexp = '/^'.$zip_code_format.'$/ui';
         		$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
         		$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
         		$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
         		$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
         		$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
         		if (!preg_match($zip_regexp, $postcode))
         			$this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
         	}
         	elseif ($zip_code_format)
         		$this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
         	elseif ($postcode AND !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
         			$this->errors[] = '<strong>'.Tools::displayError('Post/Zip Code mentioned is incorrect.').'</strong> ';
         }
         */
         //validate pincode and assign possible payment options
         $op = $cod = 0;
         Carrier::getPreferredCarriers($postcode, $cod, $op);
         if ($op == 0 && $cod == 0) {
             $this->errors[] = 'We are sorry but we do not provide service to this region as of now. However, we keep adding new locations with time and would request you to check our website a few weeks later. We apologise for the inconvenience caused. ';
         }
         if ($country->isNeedDni() and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
             $this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
         } elseif (!$country->isNeedDni()) {
             $address->dni = NULL;
         }
         if (Configuration::get('PS_TOKEN_ENABLE') == 1 and strcmp(Tools::getToken(false), Tools::getValue('token')) and self::$cookie->isLogged(true) === true) {
             $this->errors[] = Tools::displayError('Invalid token');
         }
         if ((int) $country->contains_states and !(int) $address->id_state) {
             $this->errors[] = Tools::displayError('This country requires a state selection.');
         }
         if (!sizeof($this->errors)) {
             if (isset($id_address)) {
//.........这里部分代码省略.........
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:101,代码来源:AddressController.php

示例4: finalizeOrder

 /**
  * Attempts to finalize an accepted transaction
  *
  * @result string Should be 'accepted' unless something has gone quite wrong
  */
 public function finalizeOrder($response)
 {
     global $smarty, $cart, $cookie;
     require dirname(__FILE__) . '/Rc43.php';
     $DR = $response;
     $secret_key = Configuration::get('SECRET_KEY');
     //print_r($secret_key);
     if (isset($DR)) {
         $DR = preg_replace("/\\s/", "+", $DR);
         $rc4 = new Crypt_RC4($secret_key);
         $QueryString = base64_decode($DR);
         $rc4->decrypt($QueryString);
         $QueryString = split('&', $QueryString);
         $response = array();
         foreach ($QueryString as $param) {
             $param = split('=', $param);
             $response[$param[0]] = urldecode($param[1]);
         }
         //print_r($response);
     }
     $cartID = $response['MerchantRefNo'];
     $cart = new Cart($cartID);
     $deliveryAddress = new Address($cart->id_address_delivery);
     $op = $cod = 0;
     Carrier::getPreferredCarriers($deliveryAddress->postcode, $cod, $op);
     if ($op > 0) {
         $cart->id_carrier = (int) $op;
         $cart->update();
     }
     if ($response['ResponseCode'] == 0) {
         $responseMsg = "Your Order has Been Processed";
     } else {
         $responseMsg = "Transaction Failed, Retry!!";
     }
     $cart = new Cart(intval($response['MerchantRefNo']));
     //echo "<pre>";print_r($cart);
     //if (!$cart->id)
     //	return $this->l('Cart not found');
     if ($response['ResponseCode'] == 0) {
         $status = _PS_OS_PREPARATION_;
     } else {
         $status = Configuration::get('EBS_ID_ORDER_FAILED');
     }
     $this->validateOrder($response['MerchantRefNo'], $status, $response['Amount'], $this->displayName, $this->l('EBS transaction ID: ') . $response['PaymentID'], $response['ResponseMessage']);
     $customer = new Customer((int) $cart->id_customer);
     if ($response['ResponseCode'] == 0) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->id . '&id_order=' . (int) $this->currentOrder);
     }
     $smarty->assign(array('this_path' => $this->_path, 'responseMsg' => $responseMsg, 'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/' . $this->name . '/'));
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:55,代码来源:EBS.php


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