bigcommerce / checkout-sdk-js

BigCommerce Checkout JavaScript SDK
MIT License
132 stars 215 forks source link

How to acces the Tax total? #639

Closed fresh5447 closed 5 years ago

fresh5447 commented 5 years ago

I see there is a tax interface: and I have found a reference to tax in another issue, but I can't seem to find the tax property in any of the returned states that I look at.

Which part of the state is tax supposed to belong to? I was thinking maybe shipping consignments.

Could someone share an example of retrieving the tax value? Thanks!

fresh5447 commented 5 years ago

Looking at the Checkout interface, it appears taxes should be a property, but it is not coming through in my data:

Screen Shot 2019-07-26 at 3 37 33 PM

I am also confused by this issue, which makes it seem tax should be accessible through consignments, but that does not come through either:

Screen Shot 2019-07-26 at 3 39 20 PM

fresh5447 commented 5 years ago

I was able to resolve the issue. Going to post my solution in case it helps someone.

I was inspecting the wrong part of the checkout state.

service.getState() does not return the full checkout resource, this is what I was mistakingly looking for.

The proper way to get the full checkout object is:

            const state = service.loadCheckout();
            const checkoutData = state.data.getCheckout();

Thanks happy coding!