Description
I recommend looking at the commits in order. Depends on D38431 and D38473.
Changes proposed in this Pull Request
- This PR updates composite checkout in wpcom to pass coupons to the cart endpoint and display a notice when the coupon is added successfully.
To do:
- View handling for ‘pending’ coupon submission (disable field and button, set button label to “Processing…”)
- Hide the coupon field if one has already been applied
- Add a coupon line item to the order review and order summary steps
- Make the coupon field in the summary active
- Show an error message on the field if the coupon is invalid
- Hide calypso notification on failure
- Bug fix: “Processing…” button does not appear on the review coupon field if the summary field is visible
- Bug fix: show original line item costs in review step
- Reset field error state on input
- Bug fix: Backspace twice on review order coupon field triggers step number change event
- Bug fix: Typing into review order coupon field is wonky – autocomplete appears in the wrong place and textbox loses focus on each input event
- Bug fix: Every input event in summary coupon field retriggers ‘Apply’ button animation in review order field
- Update: The deployed version of D38431 uses
coupon_discounts_integer
; need to update the response cart type to reflect this.
Testing instructions
npm run test-packages composite-checkout-wpcom
Manual steps to test basic behavior:
- Do not sandbox the store.
- Enter checkout with some products and proceed to the ‘review order’ step.
- Try to apply an invalid coupon; that is, a string not consisting only of alphanumeric characters, ‘-‘, and ‘_’. Verify that the coupon field is unhappy.
- Try to apply a valid but not active coupon such as ‘blahtestcoupon’. Verify that you see a field error and that your item and total prices do not change.
- Try to apply an active coupon. (Check with me or the field guide about how to find these.) Verify that you see a notice and that your item and total prices change appropriately, and that a ‘coupon’ line item appears in the cart with the correct price.
- Enter checkout again with a fresh cart and repeat steps 3-5, this time using the “Add coupon” link in the order summary step.
Edge cases:
- Simulate entering the cart with a coupon already applied by refreshing the page after adding a coupon. Check that the coupon line item appears in the summary step, and that the “Add a coupon” button is not visible.
Unfortunately, no screenshots were provided by the developer.