How to access individual values within address attribute type
Permalink 1 user found helpful
Hi,
In a controller file, I need to access various parts of an "address" attribute (for shipping purposes using core_commerce). When I load the address value, the entire address is a single string of text.
I can do this myself using PHP to explode etc.. but it's very messy and might not always work if c5 decides to change the way it handles addresses. I'd like to do it properly if I can.
Is there anything built into c5 that I can use to split up this value and access the individual parts of an address, eg: postcode, address line 1 etc?
How would I do this?
In a controller file, I need to access various parts of an "address" attribute (for shipping purposes using core_commerce). When I load the address value, the entire address is a single string of text.
I can do this myself using PHP to explode etc.. but it's very messy and might not always work if c5 decides to change the way it handles addresses. I'd like to do it properly if I can.
Is there anything built into c5 that I can use to split up this value and access the individual parts of an address, eg: postcode, address line 1 etc?
How would I do this?
mkly .. thanks
Brilliant mkly- THANK YOU!!!!
How about the state? I tried getState() getStateProvince() and getProvince() with no luck.
Or, where is the class defined, and I can look for myself.
thank you!
Or, where is the class defined, and I can look for myself.
thank you!
Answered my own question:
$address->getStateProvince()
$address->getStateProvince()
Regards,
Mike
http://mkly.io