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

how to reload checkout total? #1861

Open
sunilit42 opened this issue May 13, 2024 · 12 comments
Open

how to reload checkout total? #1861

sunilit42 opened this issue May 13, 2024 · 12 comments

Comments

@sunilit42
Copy link

Hello,

My client want to to remove tax class based on customer field, i already implement but not i want to reload the checkout total without pageload.

Is there any way to possible to reload total using js code?

@theromulans
Copy link

Hi @sunilit42, would you mind providing more context: which tax class are you removing from which entity? Thanks!

@bc-charlesho
Copy link

Hi @sunilit42, currently we don't have a way for you to reload the checkout using js without a hard browser refresh.

We are open to consider making checkout reload possible without a full browser refresh in a future release.

@sunilit42
Copy link
Author

@bc-charlesho

  • just listen event into checkout js and we can fire event for update total, i think quick think possible and very good useful

@bc-0dp
Copy link
Collaborator

bc-0dp commented May 14, 2024

Basically a way to trigger a state reload from outside checkout-js

@SunilP-WassDigital
Copy link

@bc-0dp can you please me how to do it?

@bc-0dp
Copy link
Collaborator

bc-0dp commented May 30, 2024

Well that's the thing, you can't. You'd have to move away from Optimized One Page Checkout and implement your logic into your own checkout-js fork.

@SunilP-WassDigital
Copy link

SunilP-WassDigital commented May 30, 2024

@bc-0dp
i already did b2b Optimized One Page Checkout fork, but not able to do it

i added packages/core/src/app/shipping/Shipping.tsx

async componentDidMount(): Promise<void> {
.....................
 let that = this;
document.addEventListener("reload-checkout", function(updateCheckout) { // (1)
                              that.props.updateCheckout({ customerMessage: '' }
        });

.................................

@bc-0dp
Copy link
Collaborator

bc-0dp commented May 30, 2024

Firstly, since it's async I believe you need await.
Secondly, I am not sure if updateCheckout is the right function, instead you might need loadCheckout

@SunilP-WassDigital
Copy link

Hello @bc-0dp

document.addEventListener("reload-checkout", function() { // (1) console.log(that) that.props.loadCheckout(that.props.checkoutId, { params: { include: [ 'cart.lineItems.physicalItems.options', 'cart.lineItems.digitalItems.options', 'customer', 'customer.customerGroup', 'payments,promotions.banners', 'consignments.availableShippingOptions' ] as any, // FIXME: Currently the enum is not exported so it can't be used here. }, }) });

i want to first reload but it is just getting data

@bc-0dp
Copy link
Collaborator

bc-0dp commented May 31, 2024

I would have to dig more around to understand how it's implemented.

@sunilit42
Copy link
Author

One more thing i found
https://developer.bigcommerce.com/docs/storefront/cart-checkout/guide/consignments

i m using this API, to update tax but if i m passing same request it does not update total, even i remove tax class
BigCommerce need to update total, seems like they are doing caching of that, is same request then don't update it

@Johnnypkoo
Copy link

Thought I'd add a comment in here as I recently encountered a similar issue, not with tax but currency. We change the currency in checkout but there is no way to refresh the state of SDK so we were presented with the mini cart showing the original currency and a message saying we will be charged in the new currency. It would be great if we could own the state and then refresh this as required. I managed to get around this by reloading the checkout with the new currency id in the query param (setCurrencyId).
I would've thought that calling loadCheckout() and passing in the new cart ID would resolve this but it was unsuccessful

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

No branches or pull requests

6 participants