Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove tax fields from cart queries unless its prepare for completion #280

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

kieran-osgood-shopify
Copy link
Contributor

What changes are you making?

There is a graphql schema issue (currently being tracked elsewhere, issue # TBT) where the total tax amount has been marked as deprecated on cart, but this should only be true for non cartCompletion requests

This PR adds an additional fragment specifically for cart completion that accesses this, and separates it from the original cart object for the sake of clarity (and safety, as the Buy sdk will throw if it you access a property that wasn't queried)

How to test

Open apple pay and ensure the requests that happen on open (cartBuyerIdentityUpdate, cartSelectedDeliveryOptionsUpdate ) do not request the totalTax amount, but the cartPrepareForCompletion after each does


Before you merge

Important


Checklist for releasing a new version
  • I have bumped the version number in the podspec file.
  • I have bumped the version number in the README.
  • I have added a Changelog entry.

Tip

See the Contributing documentation for instructions on how to publish a new version of the library.

@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner February 24, 2025 12:29
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/fix/deprecated-tax-fields branch from ab14282 to 332608a Compare February 24, 2025 12:46

do {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ensures prepare is called even if updating the shipping options fails, which happens regularly at the moment due to a 500 server error atm

let shippingContact = payment.shippingContact,
payment.shippingContact?.postalAddress?.isoCountryCode == "US"
let shippingContact = payment.shippingContact
// payment.shippingContact?.postalAddress?.isoCountryCode == "US"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disabled this us country code restriction that only applies to tiagos store, will remove this going forwards i think

* update the buyerIdentity with the shippingContact.email
*/
guard
let emailAddress = shippingContact.emailAddress,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email guard moved in to vaulted state check as we require it via apple payment so its guaranteed to be set outside of this flow

@@ -345,7 +351,7 @@ class CartManager: ObservableObject {

let mutation = Storefront.buildMutation(inContext: CartManager.ContextDirective) {
$0.cartPaymentUpdate(cartId: cartId, payment: paymentInput) {
$0.cart { $0.cartManagerFragment() }
$0.cart { $0.cartPrepareForCompletionFragment() }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change adds tax pulling for the payment update which is still not deprecated

@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as draft February 27, 2025 20:04
@kieran-osgood-shopify
Copy link
Contributor Author

I've just pushed some changes whilst debugging issues with american addresses, so converted back to draft.
Also adding a note here that the totalTaxAmount needs to be removed from cartManagerFragment before merging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant