How to Apply coupons using Rest API ?
-
Hello
How we can apply coupons to cart and checkout page using REST API. Same like WooCommerce works with ajax.
Thanks
-
Howdy 🙂
Can you explain with a bit more context what you are hoping to achieve? This makes no sense. Why would you need to add coupons to the cart and checkout page using the REST API?
Hello,
My Goal is to create a mobile application which acts like a website. why it’s too much difficulty with WooCommerce to manage cart( calculate cart total with shipping, tax, coupon, reward points etc ) with API?
How we can create one API like
e.g:
http://localhost/WooCommerce/wp-json/wc/v3/checkout_order_reviewwhere I will pass data like:
{
“billing_country”:”IN”,
“billing_state”:”JG”,
“billing_postcode”:””,
“billing_city”:””,
“billing_address_1″:””,
“billing_address_2″:””,
“ship_to_different_address”: true/false
“shipping_country”:”IN”,
“shipping_state”:”JG”,
“shipping_postcode”:””,
“shipping_city”:””,
“shipping_address_1″:””,
“shipping_address_2″:””,
“shipping_method”:[“flat_rate:6”],
“customer_id”:””,
“cart_items”:[
{
“product_id”:”30″,”quantity”:”1″,
“variation”:””
}
]
}now this API return value like
{
“show_shipping”: 1,
“shipping”: {
“methods”: [
{
“id”: “local_pickup:5”,
“label”: “Local pickup”,
“cost”: “4.00”,
“cost_display”: “£4.00”,
“method_id”: “local_pickup”
},
{
“id”: “flat_rate:6”,
“label”: “Flat rate”,
“cost”: “3.00”,
“cost_display”: “£3.00”,
“method_id”: “flat_rate”
}
],
“chosen”: “flat_rate:6”,
“index”: 0
},
“status”: “success”,
“taxes_total”: {
“code”: “”,
“label”: “VAT”,
“formatted_amount”: “<span class=\”woocommerce-Price-amount amount\”><span class=\”woocommerce-Price-currencySymbol\”>£</span>1.05</span>”,
“amount”: “1.05”
},
“order_total_html”: “<span class=\”woocommerce-Price-amount amount\”><span class=\”woocommerce-Price-currencySymbol\”>£</span>22.05</span>”,
“order_total”: “22.05”,
“rewards_message”: “”
}Something like this.
Thanks
@tushar4monto As mentioned in another thread, you seem to be going about this the wrong way. The API is there to provide access to Create, Read, Update and Delete the WooCommerce (or WordPress) data. The API is not meant to remotely control the functions within the WordPress, WooCommerce or additional plugin software.
The API is meant for developers to be able to obtain data about the store, then the data is processed within the application they are developing, and then that data is posted back to the store.
If you are needing to remotely control a website via an application, it may be better to develop a plugin that you are able to make calls to that will execute the functions needed on the server to process the data as desired.
The topic ‘How to Apply coupons using Rest API ?’ is closed to new replies.