Closed vandres closed 2 years ago
Hi @vandres I think I had the same problem as you, in the short term I've done this:
{% set areCartAddressesTheSame = (shippingAddress|address == billingAddress|address) ? 1 : 0 %}
I had to use the |address filter pipe otherwise the site would white screen of death.
Hi @vandres
Addresses on the Order element a stored as separate IDs by design.
If you would like to check if the addresses are the same you can simply call the hasMatchingAddresses()
method on the Order element e.g.
Are the addresses the same: {{ cart.hasMatchingAddresses() ? 'Yes' : 'No' }}
You mentioned some existing twig code that was causing confusion, was that in the Commerce example templates or in the Spoke & Chain demo project?
Thanks.
@nfourtythree I took the code from Spoke & Chain
Thanks for the help, will use the suggested method instead
@vandres thank you for letting us know. We will look to fix the demo project shortly.
Thanks!
Ooh, I didn't know about hasMatchingAddresses()
, thanks @nfourtythree :)
What happened?
Description
I am seeing an issue with
billingAddressSameAsShipping
in our instance. I can see the same problem in the Spoke & Chain demo instance.When selecting
billingAddressSameAsShipping
and setting a shipping address, a billing address is set, but it is never the same as the shipping address. So the following code from the checkout summary always results to false:Is that just an error in the demo code and the comparison should use "sourceXAddressId" instead?
Steps to reproduce
Expected behavior
I expect to see "Same as shipping."
Actual behavior
I see two full addresses. In the database I can also see separate addresses created for that order and two different ids on the order. What I see is two times the same "sourceXAddressId"
Craft CMS version
4.2.5
Craft Commerce version
4.1.2
PHP version
8.1
Operating system and version
MacOS, Debian Docker
Database type and version
MariaDB 10.5
Image driver and version
-
Installed plugins and versions