How to get Region text from address id (Magento 2)How to delete empty select option value in magentoRegions...
Is it 40% or 0.4%?
You'll find me clean when something is full
How would we write a misogynistic character without offending people?
CBP Reminds Travelers to Allow 72 Hours for ESTA. Why?
Why does Starman/Roadster have radial acceleration?
Can you use a beast's innate abilities while polymorphed?
What can I substitute for soda pop in a sweet pork recipe?
Must a tritone substitution use a dominant seventh chord?
Skis versus snow shoes - when to choose which for travelling the backcountry?
How do ISS astronauts "get their stripes"?
Borrowing Characters
Did 5.25" floppies undergo a change in magnetic coating?
Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?
How to deny access to SQL Server to certain login over SSMS, but allow over .Net SqlClient Data Provider
Is divide-by-zero a security vulnerability?
Auto Insert date into Notepad
If nine coins are tossed, what is the probability that the number of heads is even?
Pronunciation of powers
Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?
What type of postprocessing gives the effect of people standing out
What is the wife of a henpecked husband called?
How to properly claim credit for peer review?
What's the difference between a cart and a wagon?
chrony vs. systemd-timesyncd – What are the differences and use cases as NTP clients?
How to get Region text from address id (Magento 2)
How to delete empty select option value in magentoRegions dropdown in account creation formMagento 1.9 CE State Region confusionCustom text field for configurable product Magento 2Magento 2 : Filter dropdown value by other dropdown value : (Chained Select Boxes) in Checkout pageMagento 2 websites : BLOCK access from ALL & ALLOW access only from some countries?Magento 2 : State dropdown showing regionID is required fieldMagento 2.2: How to add country and region drop-downs in a custom step form in one page checkout?Magento 2 checkout page how to get country_id from selected shipping addresses?region Id error on updating address using address Id in magneto2
I am not able to get region text from address id,
<?php $_pAddsses = $block->getDefaultBilling() ?>
<?php echo $block->getAddressById($_pAddsses)->getRegionId() ?>
// output 5
<?php echo $block->getAddressById($_pAddsses)->getRegion() ?>
//output ""(empty)
And for my question, I don't have any region code, as many countries don't have region dropdown, like - India country dropdown doesn't have region dropdown, so in the database, the region id is 0 and region is whatever we filled in the text box for the region.
I checked the database it does contain region text.
I need region text to populate the region text box for which region dropdown
is not available for countries.
I am not able to figure out what am I doing wrong.
magento2 customer-address address regions
add a comment |
I am not able to get region text from address id,
<?php $_pAddsses = $block->getDefaultBilling() ?>
<?php echo $block->getAddressById($_pAddsses)->getRegionId() ?>
// output 5
<?php echo $block->getAddressById($_pAddsses)->getRegion() ?>
//output ""(empty)
And for my question, I don't have any region code, as many countries don't have region dropdown, like - India country dropdown doesn't have region dropdown, so in the database, the region id is 0 and region is whatever we filled in the text box for the region.
I checked the database it does contain region text.
I need region text to populate the region text box for which region dropdown
is not available for countries.
I am not able to figure out what am I doing wrong.
magento2 customer-address address regions
add a comment |
I am not able to get region text from address id,
<?php $_pAddsses = $block->getDefaultBilling() ?>
<?php echo $block->getAddressById($_pAddsses)->getRegionId() ?>
// output 5
<?php echo $block->getAddressById($_pAddsses)->getRegion() ?>
//output ""(empty)
And for my question, I don't have any region code, as many countries don't have region dropdown, like - India country dropdown doesn't have region dropdown, so in the database, the region id is 0 and region is whatever we filled in the text box for the region.
I checked the database it does contain region text.
I need region text to populate the region text box for which region dropdown
is not available for countries.
I am not able to figure out what am I doing wrong.
magento2 customer-address address regions
I am not able to get region text from address id,
<?php $_pAddsses = $block->getDefaultBilling() ?>
<?php echo $block->getAddressById($_pAddsses)->getRegionId() ?>
// output 5
<?php echo $block->getAddressById($_pAddsses)->getRegion() ?>
//output ""(empty)
And for my question, I don't have any region code, as many countries don't have region dropdown, like - India country dropdown doesn't have region dropdown, so in the database, the region id is 0 and region is whatever we filled in the text box for the region.
I checked the database it does contain region text.
I need region text to populate the region text box for which region dropdown
is not available for countries.
I am not able to figure out what am I doing wrong.
magento2 customer-address address regions
magento2 customer-address address regions
edited 17 hours ago
summu
asked 19 hours ago
summusummu
1418
1418
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can try following code to get the region from the address id.
$address = $this->addressRepository->getById($addressId);
$address->getRegion()->getRegion();
where $this->addressRepository
is the object of MagentoCustomerApiAddressRepositoryInterface
$address->getRegion()
will give return you the object of MagentoCustomerApiDataRegionInterface
and then calling getRegion()
on it will give you string.
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
|
show 2 more comments
In Block File :-
protected $AddressRepoInterface;
public function __construct(
MagentoCustomerApiAddressRepositoryInterface $AddressRepoInterface
){
$this->AddressRepoInterface = $AddressRepoInterface;
}
public function getRegionName() {
return $this->AddressRepoInterface->getById($addressId)->getRegion();
}
In phtml File :-
$block->getRegionName();
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
|
show 2 more comments
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%2f264250%2fhow-to-get-region-text-from-address-id-magento-2%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
You can try following code to get the region from the address id.
$address = $this->addressRepository->getById($addressId);
$address->getRegion()->getRegion();
where $this->addressRepository
is the object of MagentoCustomerApiAddressRepositoryInterface
$address->getRegion()
will give return you the object of MagentoCustomerApiDataRegionInterface
and then calling getRegion()
on it will give you string.
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
|
show 2 more comments
You can try following code to get the region from the address id.
$address = $this->addressRepository->getById($addressId);
$address->getRegion()->getRegion();
where $this->addressRepository
is the object of MagentoCustomerApiAddressRepositoryInterface
$address->getRegion()
will give return you the object of MagentoCustomerApiDataRegionInterface
and then calling getRegion()
on it will give you string.
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
|
show 2 more comments
You can try following code to get the region from the address id.
$address = $this->addressRepository->getById($addressId);
$address->getRegion()->getRegion();
where $this->addressRepository
is the object of MagentoCustomerApiAddressRepositoryInterface
$address->getRegion()
will give return you the object of MagentoCustomerApiDataRegionInterface
and then calling getRegion()
on it will give you string.
You can try following code to get the region from the address id.
$address = $this->addressRepository->getById($addressId);
$address->getRegion()->getRegion();
where $this->addressRepository
is the object of MagentoCustomerApiAddressRepositoryInterface
$address->getRegion()
will give return you the object of MagentoCustomerApiDataRegionInterface
and then calling getRegion()
on it will give you string.
edited 16 hours ago
answered 17 hours ago
Anshu MishraAnshu Mishra
5,44652660
5,44652660
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
|
show 2 more comments
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
I am not able to print the return value $address->getRegion(); Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
i did this <?php $regionName = $orderHelper->getRegionName($_pAddsses) ?> <?php echo "region " .$regionName ?> Recoverable Error: Object of class MagentoCustomerModelDataRegion could not be converted to string
– summu
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
Try $address->getRegion()->getRegion(); I have updated the same in my answer as well.
– Anshu Mishra
16 hours ago
why two time getRegion()
– summu
16 hours ago
why two time getRegion()
– summu
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
Check the updated answer.
– Anshu Mishra
16 hours ago
|
show 2 more comments
In Block File :-
protected $AddressRepoInterface;
public function __construct(
MagentoCustomerApiAddressRepositoryInterface $AddressRepoInterface
){
$this->AddressRepoInterface = $AddressRepoInterface;
}
public function getRegionName() {
return $this->AddressRepoInterface->getById($addressId)->getRegion();
}
In phtml File :-
$block->getRegionName();
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
|
show 2 more comments
In Block File :-
protected $AddressRepoInterface;
public function __construct(
MagentoCustomerApiAddressRepositoryInterface $AddressRepoInterface
){
$this->AddressRepoInterface = $AddressRepoInterface;
}
public function getRegionName() {
return $this->AddressRepoInterface->getById($addressId)->getRegion();
}
In phtml File :-
$block->getRegionName();
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
|
show 2 more comments
In Block File :-
protected $AddressRepoInterface;
public function __construct(
MagentoCustomerApiAddressRepositoryInterface $AddressRepoInterface
){
$this->AddressRepoInterface = $AddressRepoInterface;
}
public function getRegionName() {
return $this->AddressRepoInterface->getById($addressId)->getRegion();
}
In phtml File :-
$block->getRegionName();
In Block File :-
protected $AddressRepoInterface;
public function __construct(
MagentoCustomerApiAddressRepositoryInterface $AddressRepoInterface
){
$this->AddressRepoInterface = $AddressRepoInterface;
}
public function getRegionName() {
return $this->AddressRepoInterface->getById($addressId)->getRegion();
}
In phtml File :-
$block->getRegionName();
edited 16 hours ago
answered 19 hours ago
Ronak RathodRonak Rathod
1778
1778
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
|
show 2 more comments
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
I am getting this error Call to undefined method MagentoCustomerModelDataAddress::getRegionName()
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
This is my block file MagentoCustomerBlockAddressBook
– summu
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
check my updated answer
– Ronak Rathod
17 hours ago
from where do I get $regionId
– summu
17 hours ago
from where do I get $regionId
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
And for my question, i dont have any region code, as many countries doesnt have region dropdown, like - India country dropdown doesnt have region dropdown, so in database region code is 0 and region is whatever we filled in text box for region
– summu
17 hours ago
|
show 2 more comments
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%2f264250%2fhow-to-get-region-text-from-address-id-magento-2%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