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


PHP Object::getCountryId方法代码示例

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


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

示例1: beforeSave

 /**
  * Prepare object for save
  *
  * @param \Magento\Framework\Object $object
  * @return $this
  */
 public function beforeSave($object)
 {
     $region = $object->getData('region');
     if (is_numeric($region)) {
         $regionModel = $this->_createRegionInstance();
         $regionModel->load($region);
         if ($regionModel->getId() && $object->getCountryId() == $regionModel->getCountryId()) {
             $object->setRegionId($regionModel->getId())->setRegion($regionModel->getName());
         }
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:Region.php

示例2: _prepareArrayRow

 /**
  * Prepare existing row data object
  *
  * @param \Magento\Framework\Object $row
  * @return void
  */
 protected function _prepareArrayRow(\Magento\Framework\Object $row)
 {
     $country = $row->getCountryId();
     $options = [];
     if ($country) {
         $options['option_' . $this->getCountryRenderer()->calcOptionHash($country)] = 'selected="selected"';
         $ccTypes = $row->getCcTypes();
         if (!is_array($ccTypes)) {
             $ccTypes = [$ccTypes];
         }
         foreach ($ccTypes as $cardType) {
             $options['option_' . $this->getCcTypesRenderer()->calcOptionHash($cardType)] = 'selected="selected"';
         }
     }
     $row->setData('option_extra_attrs', $options);
     return;
 }
开发者ID:nja78,项目名称:magento2,代码行数:23,代码来源:Countrycreditcard.php

示例3: collectRatesByAddress

 /**
  * Collect rates by address
  *
  * @param \Magento\Framework\Object $address
  * @param null|bool|array $limitCarrier
  * @return $this
  */
 public function collectRatesByAddress(\Magento\Framework\Object $address, $limitCarrier = null)
 {
     /** @var $request \Magento\Sales\Model\Quote\Address\RateRequest */
     $request = $this->_shipmentRequestFactory->create();
     $request->setAllItems($address->getAllItems());
     $request->setDestCountryId($address->getCountryId());
     $request->setDestRegionId($address->getRegionId());
     $request->setDestPostcode($address->getPostcode());
     $request->setPackageValue($address->getBaseSubtotal());
     $request->setPackageValueWithDiscount($address->getBaseSubtotalWithDiscount());
     $request->setPackageWeight($address->getWeight());
     $request->setFreeMethodWeight($address->getFreeMethodWeight());
     $request->setPackageQty($address->getItemQty());
     $request->setStoreId($this->_storeManager->getStore()->getId());
     $request->setWebsiteId($this->_storeManager->getStore()->getWebsiteId());
     $request->setBaseCurrency($this->_storeManager->getStore()->getBaseCurrency());
     $request->setPackageCurrency($this->_storeManager->getStore()->getCurrentCurrency());
     $request->setLimitCarrier($limitCarrier);
     $request->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax());
     return $this->collectRates($request);
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:28,代码来源:Shipping.php

示例4: getAppliedRates

 /**
  * Get information about tax rates applied to request
  *
  * @param   \Magento\Framework\Object $request
  * @return  array
  */
 public function getAppliedRates($request)
 {
     if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) {
         return [];
     }
     $cacheKey = $this->_getRequestCacheKey($request);
     if (!isset($this->_rateCalculationProcess[$cacheKey])) {
         $this->_rateCalculationProcess[$cacheKey] = $this->_getResource()->getCalculationProcess($request);
     }
     return $this->_rateCalculationProcess[$cacheKey];
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Calculation.php

示例5: _getRates

 /**
  * Returns tax rates for request - either pereforms SELECT from DB, or returns already cached result
  * Notice that productClassId due to optimization can be array of ids
  *
  * @param \Magento\Framework\Object $request
  * @return array
  */
 protected function _getRates($request)
 {
     // Extract params that influence our SELECT statement and use them to create cache key
     $storeId = $this->_storeManager->getStore($request->getStore())->getId();
     $customerClassId = $request->getCustomerClassId();
     $countryId = $request->getCountryId();
     $regionId = $request->getRegionId();
     $postcode = $request->getPostcode();
     // Process productClassId as it can be array or usual value. Form best key for cache.
     $productClassId = $request->getProductClassId();
     $ids = is_array($productClassId) ? $productClassId : array($productClassId);
     foreach ($ids as $key => $val) {
         $ids[$key] = (int) $val;
         // Make it integer for equal cache keys even in case of null/false/0 values
     }
     $ids = array_unique($ids);
     sort($ids);
     $productClassKey = implode(',', $ids);
     // Form cache key and either get data from cache or from DB
     $cacheKey = implode('|', array($storeId, $customerClassId, $productClassKey, $countryId, $regionId, $postcode));
     if (!isset($this->_ratesCache[$cacheKey])) {
         // Make SELECT and get data
         $select = $this->_getReadAdapter()->select();
         $select->from(array('main_table' => $this->getMainTable()), array('tax_calculation_rate_id', 'tax_calculation_rule_id', 'customer_tax_class_id', 'product_tax_class_id'))->where('customer_tax_class_id = ?', (int) $customerClassId);
         if ($productClassId) {
             $select->where('product_tax_class_id IN (?)', $productClassId);
         }
         $ifnullTitleValue = $this->_getReadAdapter()->getCheckSql('title_table.value IS NULL', 'rate.code', 'title_table.value');
         $ruleTableAliasName = $this->_getReadAdapter()->quoteIdentifier('rule.tax_calculation_rule_id');
         $select->join(array('rule' => $this->getTable('tax_calculation_rule')), $ruleTableAliasName . ' = main_table.tax_calculation_rule_id', array('rule.priority', 'rule.position', 'rule.calculate_subtotal'))->join(array('rate' => $this->getTable('tax_calculation_rate')), 'rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id', array('value' => 'rate.rate', 'rate.tax_country_id', 'rate.tax_region_id', 'rate.tax_postcode', 'rate.tax_calculation_rate_id', 'rate.code'))->joinLeft(array('title_table' => $this->getTable('tax_calculation_rate_title')), "rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id " . "AND title_table.store_id = '{$storeId}'", array('title' => $ifnullTitleValue))->where('rate.tax_country_id = ?', $countryId)->where("rate.tax_region_id IN(?)", array(0, (int) $regionId));
         $postcodeIsNumeric = is_numeric($postcode);
         $postcodeIsRange = false;
         $originalPostcode = null;
         if (is_string($postcode) && preg_match('/^(.+)-(.+)$/', $postcode, $matches)) {
             if ($countryId == self::USA_COUNTRY_CODE && is_numeric($matches[2]) && strlen($matches[2]) == 4) {
                 $postcodeIsNumeric = true;
                 $originalPostcode = $postcode;
                 $postcode = $matches[1];
             } else {
                 $postcodeIsRange = true;
                 $zipFrom = $matches[1];
                 $zipTo = $matches[2];
             }
         }
         if ($postcodeIsNumeric || $postcodeIsRange) {
             $selectClone = clone $select;
             $selectClone->where('rate.zip_is_range IS NOT NULL');
         }
         $select->where('rate.zip_is_range IS NULL');
         if ($postcode != '*' || $postcodeIsRange) {
             $select->where("rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', ?)", $postcodeIsRange ? $postcode : $this->_createSearchPostCodeTemplates($postcode, $originalPostcode));
             if ($postcodeIsNumeric) {
                 $selectClone->where('? BETWEEN rate.zip_from AND rate.zip_to', $postcode);
             } elseif ($postcodeIsRange) {
                 $selectClone->where('rate.zip_from >= ?', $zipFrom)->where('rate.zip_to <= ?', $zipTo);
             }
         }
         /**
          * @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592
          */
         if ($postcodeIsNumeric || $postcodeIsRange) {
             $select = $this->_getReadAdapter()->select()->union(array('(' . $select . ')', '(' . $selectClone . ')'));
         }
         $select->order('priority ' . \Magento\Framework\DB\Select::SQL_ASC)->order('tax_calculation_rule_id ' . \Magento\Framework\DB\Select::SQL_ASC)->order('tax_country_id ' . \Magento\Framework\DB\Select::SQL_DESC)->order('tax_region_id ' . \Magento\Framework\DB\Select::SQL_DESC)->order('tax_postcode ' . \Magento\Framework\DB\Select::SQL_DESC)->order('value ' . \Magento\Framework\DB\Select::SQL_DESC);
         $fetchResult = $this->_getReadAdapter()->fetchAll($select);
         $filteredRates = array();
         if ($fetchResult) {
             foreach ($fetchResult as $rate) {
                 if (!isset($filteredRates[$rate['tax_calculation_rate_id']])) {
                     $filteredRates[$rate['tax_calculation_rate_id']] = $rate;
                 }
             }
         }
         $this->_ratesCache[$cacheKey] = array_values($filteredRates);
     }
     return $this->_ratesCache[$cacheKey];
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:84,代码来源:Calculation.php

示例6: _applyStreetAndRegionWorkarounds

 /**
  * Adopt specified address object to be compatible with Magento
  *
  * @param \Magento\Framework\Object $address
  * @return void
  */
 protected function _applyStreetAndRegionWorkarounds(\Magento\Framework\Object $address)
 {
     // merge street addresses into 1
     if ($address->hasStreet2()) {
         $address->setStreet(implode("\n", array($address->getStreet(), $address->getStreet2())));
         $address->unsStreet2();
     }
     // attempt to fetch region_id from directory
     if ($address->getCountryId() && $address->getRegion()) {
         $regions = $this->_countryFactory->create()->loadByCode($address->getCountryId())->getRegionCollection()->addRegionCodeOrNameFilter($address->getRegion())->setPageSize(1);
         foreach ($regions as $region) {
             $address->setRegionId($region->getId());
             $address->setExportedKeys(array_merge($address->getExportedKeys(), array('region_id')));
             break;
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:23,代码来源:Nvp.php

示例7: setShipping

 /**
  * @param Object $request
  * @param Object $shipping
  *
  * @return Object
  */
 public function setShipping($request, $shipping)
 {
     $request->setShiptofirstname($shipping->getFirstname())->setShiptolastname($shipping->getLastname())->setShiptostreet(implode(' ', $shipping->getStreet()))->setShiptocity($shipping->getCity())->setShiptostate($shipping->getRegionCode())->setShiptozip($shipping->getPostcode())->setShiptocountry($shipping->getCountryId());
     return $request;
 }
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:Payflowpro.php


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