When i try get temp order after buy product:
protected function getTempOrder($customer)
{
$address = [];
if(!empty($customer->getAddresses()) && $existingAddress = $customer->getAddresses()[0]) {
$address['street'] = implode(', ', $existingAddress->getStreet());
$address['city'] = $existingAddress->getCity();
$address['country_id'] = $existingAddress->getCountryId();
$address['region'] = $existingAddress->getRegion();
$address['region_id'] = 1;
$address['postcode'] = $existingAddress->getPostcode();
$address['telephone'] = $existingAddress->getTelephone();
$address['fax'] = $existingAddress->getFax();
} else {
$address['street'] = self::NOT_DEFINED;
$address['city'] = self::NOT_DEFINED;
$address['country_id'] = 'US';
$address['region'] = self::NOT_DEFINED;
$address['region_id'] = 1;
$address['postcode'] = '10000';
$address['telephone'] = '0123456789';
$address['fax'] = '0123456789';
}
$tempOrder = [
'currency_id' => 'CAD',
'email' => $customer->getEmail(),
'shipping_address' => [
'firstname' => $customer->getFirstname(),
'lastname' => $customer->getLastname(),
'street' => $address['street'],
'city' => $address['city'],
'country_id' => $address['country_id'],
'region' => $address['region'],
'region_id' => $address['region_id'],
'postcode' => $address['postcode'],
'telephone' => $address['telephone'],
'fax' => $address['fax'],
'save_in_address_temp' => 1
],
'items'=> [
[
'product_id' => $this->config->getProductId(),
'qty' => 1
]
]
];
return $tempOrder;
}
I see error: Please check the billing address information. Invalid value of “1” provided for the regionId field.
How i can fix this?