Plugin Support
con
(@conschneider)
Engineer
Hi there,
My clear question: where are the methods that Woocommerce use to calculate the shipping cost when the data is being filled in the checkout form? My idea is to extend that function and create a set of methods that can return me the same values as is being done already in Woo/Wordpress but I haven’t been able to find any hint.
It sounds like you are building an ecommerce app and for that I think you will need cart endpoints as well. For example via: https://wordpress.org/plugins/cart-rest-api-for-woocommerce/
Does that go into the right direction?
Kind regards,
Yes, I’m building an ecomm app. But I actually don’t need the cart features since I’m using state management to control it.
What I’m looking to do is to create a rest api endpoint that gets the shipping address of the user and it returns the possible shipping methods.
I was looking at some woocommerce blocks that uses the endpoint /wc/store/cart/update-customer in the FetchAPI but looks like it depends on the Nonce with I actually don’t know how to create.
In any case, whatever hint to create this would be helpful.
Plugin Support
con
(@conschneider)
Engineer
Hi again,
I was looking at some woocommerce blocks that uses the endpoint /wc/store/cart/update-customer in the FetchAPI but looks like it depends on the Nonce with I actually don’t know how to create.
Yes I would expect that since the shipping calculation only takes place during a session (which needs the nonce validation) and also only in cart and checkout.
However when accessing via REST API, you are already using authorisation to make validated calls, so you don’t need nonce additionally from what I understand.
For reference: https://wordpress.stackexchange.com/questions/323637/verify-nonce-in-rest-api
But I actually don’t need the cart features since I’m using state management to control it.
I see, but it sounds like you might be reinventing the wheel and therefore have to come up with your own logic.
From what I can see this would be the way to approach this: https://wordpress.stackexchange.com/questions/358732/get-woocommerce-shipping-methods-programmatically
Check cart content >> check shipping packages etc.
Hope that helps a bit.
Kind regards,
Hi,
We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, the above info was helpful.
If you have further questions, please feel free to open a new topic.
Thanks.