Magento 2, address->getRegion() return object instead of stringCustomer address data not showing all countriesMagento2 add custom address attributeBilling Address Custom FieldHow to programmatically add a “region” to the “addresInformation” on the page of the “checkout” when ordering?Magento 2 checkout page how to get country_id from selected shipping addresses?M2 : After magento upgrade not able to save “state” form address edit pageAddress update get street problem magento 2Magento 2 : DHL shipping is not giving rates for UAE webiteHow to get Region text from address id (Magento 2)
Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?
Theorems that impeded progress
How to draw the figure with four pentagons?
Facing a paradox: Earnshaw's theorem in one dimension
Is it legal for company to use my work email to pretend I still work there?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
Will google still index a page if I use a $_SESSION variable?
Can one be a co-translator of a book, if he does not know the language that the book is translated into?
I'm flying to France today and my passport expires in less than 2 months
How do I write bicross product symbols in latex?
What exploit are these user agents trying to use?
90's TV series where a boy goes to another dimension through portal near power lines
How can I tell someone that I want to be his or her friend?
AES: Why is it a good practice to use only the first 16bytes of a hash for encryption?
Why doesn't H₄O²⁺ exist?
SSH "lag" in LAN on some machines, mixed distros
What is going on with Captain Marvel's blood colour?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
What do you call someone who asks many questions?
CEO ridiculed me with gay jokes and grabbed me and wouldn't let go - now getting pushed out of company
Is it inappropriate for a student to attend their mentor's dissertation defense?
Twin primes whose sum is a cube
How could indestructible materials be used in power generation?
Intersection of two sorted vectors in C++
Magento 2, address->getRegion() return object instead of string
Customer address data not showing all countriesMagento2 add custom address attributeBilling Address Custom FieldHow to programmatically add a “region” to the “addresInformation” on the page of the “checkout” when ordering?Magento 2 checkout page how to get country_id from selected shipping addresses?M2 : After magento upgrade not able to save “state” form address edit pageAddress update get street problem magento 2Magento 2 : DHL shipping is not giving rates for UAE webiteHow to get Region text from address id (Magento 2)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to get Region from shipping address.
Here's the code :
$customer = $this->customerRepository->get('xxx@xxx.com');
$shippingAddressId = $customer->getDefaultShipping();
$shippingAddress = $this->addressRepository->getById($shippingAddressId);
$shippingAddress->getRegion();
But I'm not getting string of region name, instead I got Object from MagentoCustomerModelDataRegion
The country is not United States, so Region is simply string ( input text form ) instead of select, so no Region Id / Region Code when I created the customer from admin.
So, how correct way to get Region from shipping when there are no region id / region code?
magento2 customer-address
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm trying to get Region from shipping address.
Here's the code :
$customer = $this->customerRepository->get('xxx@xxx.com');
$shippingAddressId = $customer->getDefaultShipping();
$shippingAddress = $this->addressRepository->getById($shippingAddressId);
$shippingAddress->getRegion();
But I'm not getting string of region name, instead I got Object from MagentoCustomerModelDataRegion
The country is not United States, so Region is simply string ( input text form ) instead of select, so no Region Id / Region Code when I created the customer from admin.
So, how correct way to get Region from shipping when there are no region id / region code?
magento2 customer-address
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I'm trying to get Region from shipping address.
Here's the code :
$customer = $this->customerRepository->get('xxx@xxx.com');
$shippingAddressId = $customer->getDefaultShipping();
$shippingAddress = $this->addressRepository->getById($shippingAddressId);
$shippingAddress->getRegion();
But I'm not getting string of region name, instead I got Object from MagentoCustomerModelDataRegion
The country is not United States, so Region is simply string ( input text form ) instead of select, so no Region Id / Region Code when I created the customer from admin.
So, how correct way to get Region from shipping when there are no region id / region code?
magento2 customer-address
I'm trying to get Region from shipping address.
Here's the code :
$customer = $this->customerRepository->get('xxx@xxx.com');
$shippingAddressId = $customer->getDefaultShipping();
$shippingAddress = $this->addressRepository->getById($shippingAddressId);
$shippingAddress->getRegion();
But I'm not getting string of region name, instead I got Object from MagentoCustomerModelDataRegion
The country is not United States, so Region is simply string ( input text form ) instead of select, so no Region Id / Region Code when I created the customer from admin.
So, how correct way to get Region from shipping when there are no region id / region code?
magento2 customer-address
magento2 customer-address
edited Mar 20 '18 at 11:01
KamranKhan
374216
374216
asked Mar 19 '18 at 22:08
eluneelune
1335
1335
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I tried to look inside MagentoCustomerModelDataRegion
, and inside it there is a code :
/**
* Get region
*
* @return string
*/
public function getRegion()
return $this->_get(self::REGION);
So I use $shippingAddress->getRegion()->getRegion();
to get correct region name.
Still, the code look kinda weird, and I hope there are more answer to just use $shippingAddress->getRegion()
and got the string of region name i need.
add a comment |
Try the below code to get Region from default shipping addresss
protected $customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession
)
...
$this->customerSession = $customerSession;
parent::__construct($context);
public function getRegion()
$customer = $this->customerSession->getCustomer();
if ($customer)
$shippingAddress = $customer->getDefaultShippingAddress();
if ($shippingAddress)
return $shippingAddress->getRegion();
return null;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f218950%2fmagento-2-address-getregion-return-object-instead-of-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I tried to look inside MagentoCustomerModelDataRegion
, and inside it there is a code :
/**
* Get region
*
* @return string
*/
public function getRegion()
return $this->_get(self::REGION);
So I use $shippingAddress->getRegion()->getRegion();
to get correct region name.
Still, the code look kinda weird, and I hope there are more answer to just use $shippingAddress->getRegion()
and got the string of region name i need.
add a comment |
I tried to look inside MagentoCustomerModelDataRegion
, and inside it there is a code :
/**
* Get region
*
* @return string
*/
public function getRegion()
return $this->_get(self::REGION);
So I use $shippingAddress->getRegion()->getRegion();
to get correct region name.
Still, the code look kinda weird, and I hope there are more answer to just use $shippingAddress->getRegion()
and got the string of region name i need.
add a comment |
I tried to look inside MagentoCustomerModelDataRegion
, and inside it there is a code :
/**
* Get region
*
* @return string
*/
public function getRegion()
return $this->_get(self::REGION);
So I use $shippingAddress->getRegion()->getRegion();
to get correct region name.
Still, the code look kinda weird, and I hope there are more answer to just use $shippingAddress->getRegion()
and got the string of region name i need.
I tried to look inside MagentoCustomerModelDataRegion
, and inside it there is a code :
/**
* Get region
*
* @return string
*/
public function getRegion()
return $this->_get(self::REGION);
So I use $shippingAddress->getRegion()->getRegion();
to get correct region name.
Still, the code look kinda weird, and I hope there are more answer to just use $shippingAddress->getRegion()
and got the string of region name i need.
answered Mar 19 '18 at 22:17
eluneelune
1335
1335
add a comment |
add a comment |
Try the below code to get Region from default shipping addresss
protected $customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession
)
...
$this->customerSession = $customerSession;
parent::__construct($context);
public function getRegion()
$customer = $this->customerSession->getCustomer();
if ($customer)
$shippingAddress = $customer->getDefaultShippingAddress();
if ($shippingAddress)
return $shippingAddress->getRegion();
return null;
add a comment |
Try the below code to get Region from default shipping addresss
protected $customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession
)
...
$this->customerSession = $customerSession;
parent::__construct($context);
public function getRegion()
$customer = $this->customerSession->getCustomer();
if ($customer)
$shippingAddress = $customer->getDefaultShippingAddress();
if ($shippingAddress)
return $shippingAddress->getRegion();
return null;
add a comment |
Try the below code to get Region from default shipping addresss
protected $customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession
)
...
$this->customerSession = $customerSession;
parent::__construct($context);
public function getRegion()
$customer = $this->customerSession->getCustomer();
if ($customer)
$shippingAddress = $customer->getDefaultShippingAddress();
if ($shippingAddress)
return $shippingAddress->getRegion();
return null;
Try the below code to get Region from default shipping addresss
protected $customerSession;
public function __construct(
...
MagentoCustomerModelSession $customerSession
)
...
$this->customerSession = $customerSession;
parent::__construct($context);
public function getRegion()
$customer = $this->customerSession->getCustomer();
if ($customer)
$shippingAddress = $customer->getDefaultShippingAddress();
if ($shippingAddress)
return $shippingAddress->getRegion();
return null;
answered Mar 20 '18 at 6:51
Shireen NShireen N
670411
670411
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f218950%2fmagento-2-address-getregion-return-object-instead-of-string%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown