I am using woocommerce-rest-api to create an app of woocommerce site. To create an order in store we have to use create-order api, which requires basic all the order params. So there is a one params called shipping_lines
, in which we have to pass shipping id, it's name and shipping rate. So before creating order I called api called list-all-shipping-methods to displays all the shipping method and gives user to select shipping method, which will be pass later to create order. But the problem is that list-all-shipping-methods
returning only id
, title
, description
and _links
parameters. It not returning the rate of shipping method which I need to pass on create order api.
Can anyone please help me how to get shipping rate so I can pass it to create order ?
You can get shipping details including cost by hitting:
https://yourDomain.com/wp-json/wc/v3/shipping/zones/ID/methods/ID
but for this, you'll need
zoneID
andmethodId
For Zone ID
https://yourDomain.com/wp-json/wc/v3/shipping/zones
For method ID
https://yourDomain.com/wp-json/wc/v3/shipping/zones/<zoneID>/methods
Now you have the desire zoneID and methodID:
https://yourDomain.com/wp-json/wc/v3/shipping/zones/<zoneID>/methods/<methodID>
And if you want all the shipping methods with cost:
https://yourDomain.com/wp-json/wc/v3/shipping/zones/<zoneID>/methods