本文整理匯總了PHP中Magento\Framework\DataObject::getRegionCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObject::getRegionCode方法的具體用法?PHP DataObject::getRegionCode怎麽用?PHP DataObject::getRegionCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getRegionCode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getRegion
/**
* Export region code from address data
*
* @param DataObject $address
* @return string
*/
protected function getRegion(DataObject $address)
{
// get region code, otherwise - region, otherwise - city
return $address->getRegionCode() ?: ($address->getRegion() ?: $address->getCity());
}
示例2: _getBillingAddress
/**
* Get billing address request data
*
* @param \Magento\Framework\DataObject $address
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getBillingAddress(\Magento\Framework\DataObject $address)
{
$region = $address->getRegionCode() ? $address->getRegionCode() : $address->getRegion();
$request = ['billing_first_name' => $address->getFirstname(), 'billing_last_name' => $address->getLastname(), 'billing_city' => $address->getCity(), 'billing_state' => $region ? $region : $address->getCity(), 'billing_zip' => $address->getPostcode(), 'billing_country' => $address->getCountryId()];
// convert streets to tow lines format
$street = $this->_customerAddress->convertStreetLines($address->getStreet(), 2);
$request['billing_address1'] = isset($street[0]) ? $street[0] : '';
$request['billing_address2'] = isset($street[1]) ? $street[1] : '';
return $request;
}
示例3: setShipping
/**
* @param DataObject $request
* @param DataObject $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;
}