Tuesday, May 3, 2016

Applying coupons using woocommerce rest api

1 comment

I am developing an application using woocommerce rest api v3. Now I'm trying to integrate coupons from my woocommerce website to my application. I'm creating an order and applying coupons like this

"coupon_lines":[{         'code'=>'coupon1',         'amount'=>'1.00' }] 

I've set a usage limit per user in woocommerce website.

When I ordered directly from website, usage restrictions are applied correctly.i.e, a user cannot use a coupon when a limit is reached. But when I make an order via REST api, the restrictions are not applied.

Additionally, I got reply from another forum stating that coupon apply feature is not yet available via rest api. But, while looking through the code of create_order api endpoint, I found that the webhook for applying coupon is called there.

 do_action( 'woocommerce_order_add_coupon', $this->id, $item_id, $code, $discount_amount, $discount_amount_tax );  

in add_coupon(). But I didn't find the add_action('woocommerce_order_add_coupon',...) . Can anyone tell me where should I write this action definition so that it shouldn't get overwritten when updating woocommerce.

1 Answers

Answers 1

Can you please add coupons id and after check?

"coupon_lines":[{         'id' => '',         'code'=>'coupon1',         'amount'=>'1.00' }] 
If You Enjoyed This, Take 5 Seconds To Share It

1 comment:

  1. Looking for woocommerce Rest API Integration for your online store? Hire our developers & programmers for your custom API and extensions ... +91-9806724185 or Contact@expresstechsoftwares.com

    ReplyDelete