関数
AmazonMiddleware::getDeliveryAddressFromCheckoutSession( array $checkoutSession )
Returns delivery address parsed from an Amazon Checkout Session
パラメータ パラメータ
- $checkoutSession
(配列) (必須)
ファイル: src/Routing/AmazonMiddleware.php
public function getDeliveryAddressFromCheckoutSession($checkoutSession) { $opts = $this->module->getActingOpts(); $sandbox = $opts['sandbox']; $address = $checkoutSession['shippingAddress']; $pref = $address['stateOrRegion']; $deliveryFullname = explode(' ', $address['name']); $deliveryName1 = $deliveryFullname[0]; $deliveryName2 = isset($deliveryFullname[1]) ? join(' ', array_slice($deliveryFullname, 1)) : ''; // set flag to 1 because address is pulled from Amazon account $delivery = []; $delivery['delivery_flag'] = 1; $delivery['name1'] = $deliveryName1; $delivery['name2'] = $deliveryName2; $delivery['name3'] = ''; $delivery['name4'] = ''; $delivery['country'] = $address['countryCode']; $delivery['fax'] = ''; $delivery['pref'] = $pref; $delivery['tel'] = $address['phoneNumber']; $delivery['zipcode'] = $address['postalCode']; $delivery['address1'] = $sandbox ? $address['city'] . $address['addressLine1'] : $address['addressLine1']; $delivery['address2'] = $address['addressLine2']; $delivery['address3'] = $address['addressLine3']; // make sure Japanese prefecture name is converted to Japanese if it is in English if ($delivery['country'] === 'JP') { if (array_key_exists($delivery['pref'], Constants::ETOJ_PREF_MAP) === true) { $delivery['pref'] = Constants::ETOJ_PREF_MAP[$delivery['pref']]; } } elseif ($delivery['country'] === 'US') { $states = get_option('usces_states'); if (!in_array($delivery['pref'], $states, true)) { if (array_key_exists($delivery['pref'], Constants::ISO_US_STATE_CODE_MAP) === true) { $delivery['pref'] = Constants::ISO_US_STATE_CODE_MAP[$delivery['pref']]; } } } return $delivery; }