"customer_user_agent": "WooCommerce API Client-Node.js/1.4.2", As @claudiosanches already said WC apis are not going to do any calculation for you, they just register a coupon you either need to do your math on the consumer side or via a custom endpoint. If any auto-apply coupon is not applying, make sure that it’s valid for the cart. "sku": "654613612", "currency": "USD", @claudiosanches Got your point. Skip to main content. You signed in with another tab or window. "first_name": "Ram", Still no updates about applying coupons with the REST API however I found another hacky way to do things (less hacky than using refund): you can set discount_line to keep a track about your coupon but the real way to change the discount field is changing the total of each items when you set your data object for the creation of the new order using REST API ( WooCommerce.post('orders', data..... ). If i am not clear enough to explain my issue please just leave a comment before closing the topic. } Description is an optional field thatâs not visible to customers, only to merchants. 2.3.1.1 Click âCreate your first couponâ or âAdd couponâ to create a new coupon. "shipping_tax": "0.00", Know how you can automatically apply coupons on your WooCommerce store. @basanthalluri I know it's the whole point here :) You need to implement as per my suggestions above. "created_via": "rest-api", Bulk Edit Product Prices With WooCommerce. The text was updated successfully, but these errors were encountered: You don't apply coupons on REST API, you can register the coupon, but WooCommerce still don't have anything to apply or calculate the value of a coupon. ] As I pointed out back in September everything related to coupon discounts is done within the cart and this class basically doesn't account stateless scenarios. 1) Disable coupon code completely on your WooCommerce store. Furthermore: WooCommerce - the most customizable eCommerce platform for building your online business. "company": "", Sign up for a free GitHub account to open an issue and contact its maintainers and the community. @Lewiscowles1986 I'm sorry I do not have write access. Successfully merging a pull request may close this issue. @basanthalluri I didn't check if something changed with WC 2.7 but as far as I could see the "right" way is to expose cart's methods to a custom endpoint. On my site I have a woocommerce theme which allows you to add account funds and pay for it in the cart. "country": "India", It's not a bug, it s won't fix UNTIL we add discount calculation classes which are planned for 2.8 milestone. Discount totals are calculated automatically and don't need to be manually set. You signed out in another tab or window. add "total", "price" and "subtotal" When it detects that the coupon is allowed to be applied, it applies it. "address_1": "969 Market", By clicking “Sign up for GitHub”, you agree to our terms of service and The following are two ways to apply a discount coupon automatically to a customerâs purchase: 1. "date_paid": "2017-02-07 04:25:53", @mikejolley, Can i know when 2.8 milestone will be released? } Example- Only apply coupon code for Giftwarp products, 9code.info. when you changed billing or shipping address) Add this block of codes into your functions.php. "meta": [] Copyright WooCommerce 2021. "href": "http://campstore.myworkdemo.com/wp-json/wc/v1/orders/2161" "payment_method_title": "Direct Bank Transfer", } "last_name": "Kumar", Go to your WooCommerce dashboard -> Products -> ⦠"taxes": [] woocommerce_checkout_update_order_review â The action hook that gets called every time the checkout is updated (e.g. "total_tax": "0.00", I tried to figure out how to accomplish this task on a custom endpoint but got stuck at some point. https://trello.com/c/wdRNLlIA/92-calculate-coupons-using-rest-api, https://developer.wordpress.org/reference/functions/wp_set_current_user/#user-contributed-notes, https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties, https://github.com/woocommerce/wc-api-dev. You don't apply coupons on REST API, you can register the coupon, but WooCommerce still don't have anything to apply or calculate the value of a coupon. 'quantity' => 1, ], Enter the coupon code, say GRAB100 or something of that sort. "order_key": "wc_order_58994c4f836f7", Sign in If you’ve enabled this setting in more than 5 coupons, the plugin will consider only the first 5 coupons on which this setting was enabled. { "customer_note": "", So, the first step is to create a coupon in WooCommerce. Woocommerce before apply coupon hook. Woocommerce before apply coupon hook. I can imagine (not tested, just thinking) this basic flow: WooCommerce - rename the "Have a Coupon?" WooCommerce coupon codes are great to convert more sales â but sometimes they get users to pause / stop placing the order until they find a coupon code online (you did it too, I know). Before creating your order you will have to set the total field of this item to $80 ($100 - $20).