@@ -50,7 +50,7 @@ curl -X POST https://example.com/wc-api/v3/coupons \
50
50
"coupon": {
51
51
"code": "new-coupon",
52
52
"type": "percent",
53
- "amount": "10" ,
53
+ "amount": 10 ,
54
54
"individual_use": true,
55
55
"product_ids": [],
56
56
"exclude_product_ids": [],
@@ -75,7 +75,7 @@ var data = {
75
75
coupon: {
76
76
code: ' new-coupon' ,
77
77
type: ' percent' ,
78
- amount: ' 10 ' ,
78
+ amount: 10 ,
79
79
individual_use: true ,
80
80
product_ids: [],
81
81
exclude_product_ids: [],
@@ -99,12 +99,41 @@ WooCommerce.post('coupons', data, function(err, data, res) {
99
99
});
100
100
```
101
101
102
+ ``` php
103
+ <?php
104
+ $data = [
105
+ 'coupon' => [
106
+ 'code' => 'new-coupon',
107
+ 'type' => 'percent',
108
+ 'amount' => 10,
109
+ 'individual_use' => true,
110
+ 'product_ids' => [],
111
+ 'exclude_product_ids' => [],
112
+ 'usage_limit' => '',
113
+ 'usage_limit_per_user' => '',
114
+ 'limit_usage_to_x_items' => '',
115
+ 'expiry_date' => '',
116
+ 'enable_free_shipping' => false,
117
+ 'product_category_ids' => [],
118
+ 'exclude_product_category_ids' => [],
119
+ 'exclude_sale_items' => true,
120
+ 'minimum_amount' => '100.00',
121
+ 'maximum_amount' => '0.00',
122
+ 'customer_emails' => [],
123
+ 'description' => ''
124
+ ]
125
+ ];
126
+
127
+ print_r($woocommerce->post('coupons', $data));
128
+ ?>
129
+ ```
130
+
102
131
``` python
103
132
data = {
104
133
" coupon" : {
105
134
" code" : " new-coupon" ,
106
135
" type" : " percent" ,
107
- " amount" : " 10 " ,
136
+ " amount" : 10 ,
108
137
" individual_use" : True ,
109
138
" product_ids" : [],
110
139
" exclude_product_ids" : [],
@@ -131,7 +160,7 @@ data = {
131
160
coupon: {
132
161
code: " new-coupon" ,
133
162
type: " percent" ,
134
- amount: " 10 " ,
163
+ amount: 10 ,
135
164
individual_use: true ,
136
165
product_ids: [],
137
166
exclude_product_ids: [],
@@ -197,13 +226,6 @@ This API lets you retrieve and view a specific coupon by ID or code.
197
226
</div>
198
227
</div >
199
228
200
- <div class =" api-endpoint " >
201
- <div class="endpoint-data">
202
- <i class="label label-get">GET</i>
203
- <h6>/wc-api/v3/coupons/code/<code></h6>
204
- </div>
205
- </div >
206
-
207
229
``` shell
208
230
curl https://example.com/wc-api/v3/coupons/529 \
209
231
-u consumer_key:consumer_secret
@@ -215,6 +237,10 @@ WooCommerce.get('coupons/529', function(err, data, res) {
215
237
});
216
238
```
217
239
240
+ ``` php
241
+ <?php print_r($woocommerce->get('coupons/529')); ?>
242
+ ```
243
+
218
244
``` python
219
245
print (wcapi.get(" coupons/529" ).json())
220
246
```
@@ -278,6 +304,10 @@ WooCommerce.get('coupons', function(err, data, res) {
278
304
});
279
305
```
280
306
307
+ ``` php
308
+ <?php print_r($woocommerce->get('coupons')); ?>
309
+ ```
310
+
281
311
``` python
282
312
print (wcapi.get(" coupons" ).json())
283
313
```
@@ -386,15 +416,15 @@ curl -X PUT https://example.com/wc-api/v3/coupons/529 \
386
416
-H " Content-Type: application/json" \
387
417
-d ' {
388
418
"coupon": {
389
- "amount": "5"
419
+ "amount": 5
390
420
}
391
421
}'
392
422
```
393
423
394
424
``` javascript
395
425
var data = {
396
426
coupon: {
397
- amount: ' 5 '
427
+ amount: 5
398
428
}
399
429
};
400
430
@@ -403,10 +433,22 @@ WooCommerce.put('coupons/529', data, function(err, data, res) {
403
433
});
404
434
```
405
435
436
+ ``` php
437
+ <?php
438
+ $data = [
439
+ 'coupon' => [
440
+ 'amount' => 5
441
+ ]
442
+ ];
443
+
444
+ print_r($woocommerce->put('coupons/529', $data));
445
+ ?>
446
+ ```
447
+
406
448
``` python
407
449
data = {
408
450
" coupon" : {
409
- " amount" : " 5 "
451
+ " amount" : 5
410
452
}
411
453
}
412
454
@@ -416,7 +458,7 @@ print(wcapi.put("coupons/529", data).json())
416
458
``` ruby
417
459
data = {
418
460
coupon: {
419
- amount: " 5 "
461
+ amount: 5
420
462
}
421
463
}
422
464
@@ -470,7 +512,7 @@ To update is necessary to send objects containing IDs and to create new not just
470
512
</div >
471
513
472
514
``` shell
473
- curl -X PUT https://example.com/wc-api/v3/coupons/bulk \
515
+ curl -X POST https://example.com/wc-api/v3/coupons/bulk \
474
516
-u consumer_key:consumer_secret \
475
517
-H " Content-Type: application/json" \
476
518
-d ' {
@@ -509,11 +551,34 @@ var data = {
509
551
]
510
552
};
511
553
512
- WooCommerce .put (' coupons/bulk' , data, function (err , data , res ) {
554
+ WooCommerce .post (' coupons/bulk' , data, function (err , data , res ) {
513
555
console .log (res);
514
556
});
515
557
```
516
558
559
+ ``` php
560
+ <?php
561
+ $data = [
562
+ 'coupons' => [
563
+ [
564
+ 'id' => 529,
565
+ 'amount' => '15.00'
566
+ ],
567
+ [
568
+ 'id' => 527,
569
+ 'minimum_amount' => '55.00'
570
+ ],
571
+ [
572
+ 'id' => 526,
573
+ 'amount': '20.00'
574
+ ]
575
+ ]
576
+ ];
577
+
578
+ print_r($woocommerce->post('coupons/bulk', $data));
579
+ ?>
580
+ ```
581
+
517
582
``` python
518
583
data = {
519
584
" coupons" : [
@@ -532,7 +597,7 @@ data = {
532
597
]
533
598
}
534
599
535
- print (wcapi.put (" coupons/bulk" , data).json())
600
+ print (wcapi.post (" coupons/bulk" , data).json())
536
601
```
537
602
538
603
``` ruby
@@ -553,7 +618,7 @@ data = {
553
618
]
554
619
}
555
620
556
- woocommerce.put (" coupons/bulk" , data).parsed_response
621
+ woocommerce.post (" coupons/bulk" , data).parsed_response
557
622
```
558
623
559
624
> JSON response example:
@@ -661,12 +726,16 @@ WooCommerce.delete('coupons/529/?force=true', function(err, data, res) {
661
726
});
662
727
```
663
728
729
+ ``` php
730
+ <?php print_r($woocommerce->delete('coupons/529', ['force' => true])); ?>
731
+ ```
732
+
664
733
``` python
665
734
print (wcapi.delete(" coupons/529?force=true" ).json())
666
735
```
667
736
668
737
``` ruby
669
- woocommerce.delete(" coupons/529? force= true" ).parsed_response
738
+ woocommerce.delete(" coupons/529" , force: true ).parsed_response
670
739
```
671
740
672
741
> JSON response example:
@@ -707,6 +776,10 @@ WooCommerce.get('coupons/count', function(err, data, res) {
707
776
});
708
777
```
709
778
779
+ ``` php
780
+ <?php print_r($woocommerce->get('coupons/count')); ?>
781
+ ```
782
+
710
783
``` python
711
784
print (wcapi.get(" coupons/count" ).json())
712
785
```
0 commit comments