Repository navigation
Conversation
| if (value.billing_address) { | ||
| // Magento resets this flag every time the shipping address is saved, | ||
| // it's set again when the billing address is saved with same_as_shipping. | ||
| value.billing_address.same_as_shipping = !!value.shipping_addresses?.[0]?.same_as_billing |
There was a problem hiding this comment.
!!... vs Boolean(...), which one do we want to use? I personally find !!... less readable on first glance.
| shipping_addresses { | ||
| uid | ||
| customer_address_id: id |
There was a problem hiding this comment.
From the magento docs:
id - Id of the customer address. (Deprecated: Use customer_address_uid instead.)
Although I don't really understand why Magento has to be weird/inconsistent once again and use uid instead of just id for that. Now I don't even really know if that variable will even work. Frustrating.
| billing_address: { | ||
| same_as_shipping: true | ||
| } | ||
| }) @@include(if: $same_as_billing) { |
There was a problem hiding this comment.
Interesting that this works! Have you checked that this doesn't introduce racing conditions within Magento? I've seen a few examples of doing these two queries together causing a database deadlock, but I don't know for sure whether that was with them merged or not.
If that's not an issue, this probably solves quite a few common bugs by itself.
| > | ||
| <div partial-submit v-on:partial-submit="(e) => mutate().then(e.detail.resolve).catch(e.detail.reject)"> | ||
| {{-- A billing address that's the same as the shipping address is updated within the shipping address mutation --}} | ||
| <div partial-submit v-on:partial-submit="(e) => variables.same_as_shipping && cart.value.billing_address?.same_as_shipping ? e.detail.resolve() : mutate().then(e.detail.resolve).catch(e.detail.reject)"> |
There was a problem hiding this comment.
I'm struggling to see why we're checking both the variables data and the cart.value.billing_address data. Does this avoid some edge case?
| {{-- Without a billing address on the cart yet we follow the checkbox of the billing address step. --}} | ||
| :before-request="(query, variables, options) => [ | ||
| variables.customer_address_id ? config.queries.setExistingShippingAddressesOnCart : query, | ||
| { ...variables, same_as_billing: cart.value.billing_address ? cart.value.billing_address.same_as_shipping : (refs.billingAddress?.data.same_as_shipping ?? true) }, |
There was a problem hiding this comment.
Same check here but then needing the ref just for this purpose. Make sure this is actually needed, otherwise this extra complexity will surely come to bite us later.
same_as_billingon theShippingCartAddress, see: magento/magento2@c11743e#diff-915fbad5fa41d92498826791e829d3a5ec4384d47432d764d602bdb56471097eR321idon theCartAddressInterface, see: magento/magento2@0abf59f#diff-915fbad5fa41d92498826791e829d3a5ec4384d47432d764d602bdb56471097eR297With those 2 we can remove the manual address comparison and we do not have to search for address ID's within customer addresses anymore.
Ref: RAP-1879 + RAP-1634