-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi-cocart-plus-v2-collection.yaml
More file actions
4053 lines (4043 loc) · 148 KB
/
Copy pathopenapi-cocart-plus-v2-collection.yaml
File metadata and controls
4053 lines (4043 loc) · 148 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: CoCart Plus - API v2
version: 2.0.0
description: |
CoCart Plus extends the CoCart REST API v2 with additional cart endpoints (mini cart,
coupons, fees, removing all items, setting shipping methods), product shipping rate
calculation, customer account endpoints (including orders and subscriptions) and
customer registration.
Requires CoCart Starter v5.0+ to be installed and active.
When the geolocation feature is enabled, responses include `Country`,
`Country-Code`, `Region` and `Timezone` headers.
When rate limiting is enabled, responses include `RateLimit-Limit`,
`RateLimit-Remaining` and `RateLimit-Reset` headers (plus `RateLimit-Retry-After`
on 429 responses).
termsOfService: https://cocartapi.com/terms-of-conditions-polar/
contact:
email: support@cocartapi.com
license:
name: GNU General Public License v3.0
url: http://www.gnu.org/licenses/gpl-3.0.html
externalDocs:
description: Find out more about CoCart API
url: https://docs.cocartapi.com
servers:
- url: '{protocol}://{host}/wp-json/cocart/v2'
description: API v2
variables:
protocol:
enum:
- http
- https
default: https
host:
default: example-store.com
description: Your store domain
tags:
- name: mini-cart
description: Operations for a lightweight mini cart response
- name: coupons
description: Operations for managing coupons applied to the cart
- name: fees
description: Operations for managing cart fees
- name: cart-items
description: Operations for managing cart items
- name: shipping
description: Operations for managing shipping on the cart
- name: products
description: Operations for product shipping calculations
- name: my-account
description: Operations for the customer account dashboard, downloads, orders and subscriptions
- name: customers
description: Operations for registering customers
paths:
/cart/mini:
get:
tags:
- mini-cart
summary: Get mini cart
description: |
Returns a lightweight version of the cart scoped to only the fields needed
to render a mini cart: items, item count, currency and subtotal.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
responses:
'200':
description: Mini cart retrieved successfully.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/MiniCart'
example:
cart_hash: e629fa6598d732768f7c726b4b621285
cart_key: cb7a23af96a3f23af3c28a8b4b8c6d5e
currency:
currency_code: USD
currency_symbol: $
currency_symbol_pos: left
currency_minor_unit: 2
currency_decimal_separator: .
currency_thousand_separator: ','
currency_prefix: $
currency_suffix: ''
item_count: 2
items:
- item_key: 6364d3f0f495b6ab9dcf8d3b5c6e0b01
id: 123
name: Premium Quality T-Shirt
price: '1800'
quantity: 2
variation: []
cart_item_data: {}
featured_image: https://example-store.com/wp-content/uploads/2024/03/tshirt.jpg
subtotal: '3600'
'403':
description: Forbidden - the minimum required version of CoCart is not installed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_minimum_version_required
message: You do not have the minimum required version of CoCart installed to use this endpoint.
data:
status: 403
/cart/coupons:
get:
tags:
- coupons
summary: Get applied coupons
description: |
Returns the coupons applied to the cart with the discount totals for each coupon.
parameters:
- $ref: '#/components/parameters/CartKey'
responses:
'200':
description: Applied coupons retrieved successfully.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AppliedCouponDetailed'
example:
- coupon: summer10
label: 'Coupon: summer10'
discount_type: percent
totals:
discount: '360'
discount_tax: '0'
'404':
description: Not found - coupons are not enabled or no coupons are applied.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
not_enabled:
summary: Coupons not enabled
value:
code: cocart_coupons_not_enabled
message: Coupons are not enabled for this store!
data:
status: 404
none_applied:
summary: No coupons applied
value:
code: cocart_cart_no_coupons_applied
message: No coupons are applied to the cart!
data:
status: 404
delete:
tags:
- coupons
summary: Remove all coupons
description: |
Removes all coupons applied to the cart and returns the updated cart.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
responses:
'200':
description: All coupons removed. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - coupons are not enabled for this store.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_coupons_not_enabled
message: Coupons are not enabled for this store!
data:
status: 404
/cart/coupons/validate:
get:
tags:
- coupons
summary: Validate applied coupons
description: |
Checks all coupons applied to the cart to see if they are still valid.
Invalid or expired coupons are removed from the cart. Coupons with email
restrictions are checked against the customers billing email. The updated
cart is returned with notices describing the validation results.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
- name: email
in: query
description: Customers billing email address used to check coupons restricted to certain email addresses.
schema:
type: string
format: email
required: false
responses:
'200':
description: Coupons validated. Returns the updated cart with validation notices.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - coupons are not enabled for this store.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_coupons_not_enabled
message: Coupons are not enabled for this store!
data:
status: 404
/cart/apply-coupon:
post:
tags:
- coupons
summary: Apply coupon to cart
description: |
Applies a coupon code to the cart and returns the updated cart. If the coupon
is already applied, the cart is returned with an informational notice.
Coupons with email restrictions are checked against the customers billing
email when provided.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
code:
description: Coupon code to apply to the cart.
type: string
email:
description: Customers email address used to check coupons restricted to certain email addresses.
type: string
format: email
required:
- code
example:
code: summer10
responses:
'200':
description: Coupon applied. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - coupons not enabled, no code provided, cart empty or coupon does not exist.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
coupons_not_enabled:
summary: Coupons are not enabled for this store
value:
code: cocart_coupons_not_enabled
message: Coupons are not enabled for this store!
data:
status: 404
code_required:
summary: No coupon code provided
value:
code: cocart_coupon_code_required
message: No coupon code provided!
data:
status: 404
not_exist:
summary: Coupon does not exist
value:
code: cocart_coupon_not_exist
message: Coupon "summer10" does not exist!
data:
status: 404
cannot_add:
summary: Cart is empty
value:
code: cocart_coupon_cannot_add
message: Coupon cannot be applied to cart with no items.
data:
status: 404
/cart/coupons/{code}:
delete:
tags:
- coupons
summary: Remove coupon by code
description: |
Removes a single coupon from the cart by its coupon code and returns the updated cart.
parameters:
- name: code
in: path
description: The coupon code to remove from the cart.
required: true
schema:
type: string
pattern: ^[\w-]+$
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
responses:
'200':
description: Coupon removed. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - coupons are not enabled, no code provided, or the coupon is not applied to the cart.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
coupons_not_enabled:
summary: Coupons are not enabled for this store
value:
code: cocart_coupons_not_enabled
message: Coupons are not enabled for this store!
data:
status: 404
code_required:
summary: No coupon code provided
value:
code: cocart_coupon_required
message: No coupon code provided!
data:
status: 404
not_applied:
summary: Coupon is not applied to the cart
value:
code: cocart_cart_coupon_invalid_code
message: Coupon does not exist in the cart.
data:
status: 404
/cart/add-fee:
post:
tags:
- fees
summary: Add fee to cart
description: |
Adds a fee to the cart. The fee is stored in session and applied when cart
totals are calculated. Returns the updated cart. If the same fee was already
added, the cart is returned with an informational notice.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
description: Name of the fee.
type: string
amount:
description: Amount for the fee as a decimal string (e.g. "10.00"). Use a negative amount for a discount.
type: string
taxable:
description: Determines if the fee is taxable.
type: boolean
default: false
tax_class:
description: The tax class the fee applies to.
type: string
required:
- name
- amount
example:
name: Handling Fee
amount: '10.00'
taxable: true
responses:
'200':
description: Fee added. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - fee name or amount missing, or cart is empty.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
missing_name:
summary: Fee name missing
value:
code: cocart_fee_missing_name
message: Name of fee is missing!
data:
status: 404
missing_amount:
summary: Fee amount missing
value:
code: cocart_fee_missing_amount
message: Fee amount is missing!
data:
status: 404
cannot_add:
summary: Cart is empty
value:
code: cocart_fee_cannot_add
message: Fee cannot be applied to cart with no items.
data:
status: 404
/cart/remove-fees:
post:
tags:
- fees
summary: Remove all fees
description: |
Removes all fees from the cart and returns the updated cart.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
responses:
'200':
description: All fees removed. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
/cart/items:
delete:
tags:
- cart-items
summary: Remove all items
description: |
Removes all items from the cart and returns the updated (empty) cart.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
- $ref: '#/components/parameters/IfNoneMatch'
- $ref: '#/components/parameters/SkipCache'
responses:
'200':
description: All items removed. Returns the updated cart.
headers:
ETag:
$ref: '#/components/headers/ETagHeader'
CoCart-Cache:
$ref: '#/components/headers/CoCartCacheHeader'
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'304':
description: Not Modified - cart unchanged since the ETag provided in If-None-Match.
headers:
ETag:
$ref: '#/components/headers/ETagHeader'
CoCart-Cache:
$ref: '#/components/headers/CoCartCacheHeader'
/cart/set-shipping-method:
post:
tags:
- shipping
summary: Set shipping method
description: |
Sets the chosen shipping method for a shipping package (or all packages when
no package ID is provided) and returns the updated cart with recalculated totals.
parameters:
- $ref: '#/components/parameters/CartKey'
- $ref: '#/components/parameters/Fields'
- $ref: '#/components/parameters/Thumb'
- $ref: '#/components/parameters/DefaultCart'
- $ref: '#/components/parameters/Formatted'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
rate_id:
description: The chosen rate ID for the package (e.g. "flat_rate:1").
type: string
package_id:
description: The ID of the package being shipped. Leave blank to apply to all packages.
oneOf:
- type: integer
nullable: true
- type: string
nullable: true
required:
- rate_id
example:
rate_id: flat_rate:1
package_id: 0
responses:
'200':
description: Shipping method set. Returns the updated cart.
headers:
Country:
$ref: '#/components/headers/GeoCountry'
Country-Code:
$ref: '#/components/headers/GeoCountryCode'
Region:
$ref: '#/components/headers/GeoRegion'
Timezone:
$ref: '#/components/headers/GeoTimezone'
RateLimit-Limit:
$ref: '#/components/headers/RateLimitLimit'
RateLimit-Remaining:
$ref: '#/components/headers/RateLimitRemaining'
RateLimit-Reset:
$ref: '#/components/headers/RateLimitReset'
content:
application/json:
schema:
$ref: '#/components/schemas/CartV2'
'404':
description: Not found - shipping is disabled, no rate ID provided, or shipping hasn't been calculated yet for the cart.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
shipping_disabled:
summary: Shipping is disabled for this store
value:
code: cocart_shipping_disabled
message: Shipping is disabled.
data:
status: 404
missing_rate_id:
summary: No rate ID provided
value:
code: cocart_missing_rate_id
message: Invalid Rate ID.
data:
status: 404
not_calculated:
summary: Applying to all packages, but shipping hasn't been calculated yet
value:
code: cocart_shipping_not_calculated
message: Customer has not calculated shipping.
data:
status: 404
/products/{id}/shipping-rates:
get:
tags:
- products
summary: Get product shipping rates
description: |
Calculates and returns the available shipping rates for a product before it
is added to the cart. The product is temporarily added to a cart simulation
so that quantity-dependent shipping prices calculate correctly, then removed.
This endpoint is stateless: passing a `cart_key` is rejected with a 403 error
because shipping rate calculation must not be associated with a specific cart.
External and grouped product types cannot be calculated and return a 403 error.
The `id` may also be a SKU, resolved to a product ID first.
parameters:
- name: id
in: path
description: Unique identifier for the product or variation ID.
required: true
schema:
type: string
- name: quantity
in: query
description: Quantity of this item to simulate adding to the cart.
required: false
schema:
type: string
default: '1'
- name: variation
in: query
description: Variable attributes that identify the variation of the item.
required: false
style: deepObject
explode: true
schema:
type: object
additionalProperties:
type: string
- name: item_data
in: query
description: Additional item data passed to make item unique.
required: false
style: deepObject
explode: true
schema:
type: object
additionalProperties: true
responses:
'200':
description: Shipping rates calculated successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/ProductShippingRates'
example:
item_key: 6364d3f0f495b6ab9dcf8d3b5c6e0b01
id: 123
parent_id: 0
name: Premium Quality T-Shirt
type: simple
item_match: true
packages:
'1':
rates:
flat_rate:1:
key: flat_rate:1
method_id: flat_rate
instance_id: 1
label: Flat rate
cost: '1000'
html: 'Flat rate: $10.00'
taxes: '0'
meta_data:
items: Premium Quality T-Shirt × 1
formatted_destination: Beverly Hills, CA 90210, United States (US)
'403':
description: Forbidden - product type cannot be calculated or a cart key was passed.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
cart_key_denied:
summary: Cart key passed
value:
code: cocart_calculate_product_shipping_rates_cart_access_denied
message: DO NOT associate a cart when calculating shipping rates for a product!
data:
status: 403
external_denied:
summary: External product
value:
code: cocart_calculate_product_shipping_external_types_denied
message: This product is external, therefore it cannot be calculated for shipping rates.
data:
status: 403
grouped_denied:
summary: Grouped product
value:
code: cocart_calculate_product_shipping_grouped_types_denied
message: This product is a group of products, therefore it cannot be calculated for shipping rates.
data:
status: 403
'404':
description: Not found - the product ID, SKU or variation is invalid or missing.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
examples:
invalid_product:
summary: Product is invalid (unpublished, or has no valid ID)
value:
code: cocart_invalid_product
message: This product is invalid.
data:
status: 404
invalid_variation:
summary: Variation ID does not belong to the parent product
value:
code: cocart_variation_invalid_id
message: Invalid variation ID.
data:
status: 404
product_id_required:
summary: No product ID or SKU provided
value:
code: cocart_product_id_required
message: Product ID number is required!
data:
status: 404
unknown_product_id:
summary: Product ID or SKU does not match any product
value:
code: cocart_unknown_product_id
message: Product does not exist! Check that you have submitted a product ID or SKU ID correctly for a product that exists.
data:
status: 404
not_loaded:
summary: CoCart core is not active
value:
code: cocart_not_loaded
message: Either the core of CoCart is not active or a specific class required does not exist.
data:
status: 404
'405':
description: Method not allowed - the resolved product ID is not numeric.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_product_id_not_numeric
message: Product ID must be numeric!
data:
status: 405
'500':
description: Internal server error - the product could not be added to the shipping calculation.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_calculate_product_shipping_rates_failed
message: Product could not be calculated!
data:
status: 500
/my-account:
get:
tags:
- my-account
summary: Get account details
description: |
Returns details of the authenticated customer's account including addresses,
order count, total spent and the most recent order.
responses:
'200':
description: Account details retrieved successfully.
content:
application/json:
schema:
$ref: '#/components/schemas/Account'
example:
user:
id: 42
date_registered: '2024-03-15T10:30:00Z'
email: john.doe@example.com
first_name: John
last_name: Doe
display_name: John Doe
addresses:
billing:
first_name: John
last_name: Doe
company: Acme Corporation
address_1: 123 Main Street
address_2: Suite 100
city: Beverly Hills
state: CA
postcode: '90210'
country: US
email: john.doe@example.com
phone: +1-555-123-4567
shipping:
first_name: John
last_name: Doe
company: ''
address_1: 123 Main Street
address_2: Suite 100
city: Beverly Hills
state: CA
postcode: '90210'
country: US
orders_count: 12
total_spent: $1,254.00
is_paying_customer: true
avatar_url: https://secure.gravatar.com/avatar/abc123
recent_order:
order_id: 1234
order_date: March 12, 2026
order_data: https://example-store.com/wp-json/cocart/v2/my-account/orders/1234
meta:
is_customer_outside_base: false
is_vat_exempt: false
extensions:
email_verification:
verified: false
'400':
description: Bad request - the customer could not be retrieved.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_customer_error
message: Unable to retrieve customer.
data:
status: 400
'403':
description: Forbidden - you need to be logged in to view the account.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
code: cocart_access_my_account_denied
message: You need to be logged in to view account!
data:
status: 403
security:
- basicAuth: []
- bearerAuth: []
post:
tags:
- my-account
summary: Update account details
description: |
Updates the authenticated customer's account details. First name, last name,
display name and email address are required (filterable via the
`cocart_save_account_details_required_fields` filter). To change the password,
provide the current password along with the new password entered twice.
Changed name and email values are kept in sync with the billing address.
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
account_first_name:
description: First name.
type: string
account_last_name:
description: Last name.
type: string
account_display_name:
description: Display name. Cannot be an email address.
type: string
account_email:
description: Email address.
type: string
format: email
password_current:
description: Current password. Required when changing the password.
type: string
password_1:
description: New password.
type: string