Expose discount_type
in Store API coupon endpoints
#3399
Conversation
Size Change: 0 B Total Size: 1.12 MB ℹ️ View Unchanged
|
@mikejolley I see in the schema for coupons that most fields have For coupons, I'm thinking the only one that we allow POST for is the coupon ID. The rest (coupon type, discount etc) are all read-only. Should we change the schema to Or ... am I completely misunderstanding the meaning of |
Context means the place this request is going to be consumed in, and it would return extra fields depending on that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it works fine, it exposed WCS coupons types just fine, and the data is passed in useStoreCartCoupons
and useStoreCart
so no extra handling is required there.
@@ -8,6 +8,7 @@ | |||
* | |||
* @internal This API is used internally by Blocks--it is still in flux and may be subject to revisions. | |||
* @since 2.5.0 | |||
* @since $VID:$ Coupon type (`discount_type`) added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This API is not public yet so I don't think we need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though it's not public I still think it's useful to track when fields are added or schema changed – doesn't hurt right?
Fixes #3274
Screenshots
Example after
POST
ing two coupons in cart,POST /wc/store/cart/apply-coupon
How to test the changes in this Pull Request:
Changelog