Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To support a checkout pane and custom checkout flows, the coupon redemption form must be built out of a reusable element. This element will render the coupon code and apply button. The order will be passed via an element attribute. This also will allow us to put coupon redemption on the cart page.
It will need
- #order: the order to act on
- #use_ajax: to decide if it should use AJAX for submission
Note: you may not want AJAX so you do not need to build AjaxCommands to render output.
Comment | File | Size | Author |
---|---|---|---|
#4 | commerce2x-coupon-redeem-update.gif | 85.78 KB | mglaman |
Comments
Comment #2
mglamanhttps://github.com/drupalcommerce/commerce/pull/651
Element up. Not tested and no tests.
Comment #3
mglamanPR https://github.com/drupalcommerce/commerce/pull/651
PR is up, has a functional test to verify element works. I've added the #use_ajax switch but disabled it at first. A test module alters the cart forms and adds coupon redemption inline, for testing and proof of concept to embedding on the cart page.
Comment #4
mglamanHere's a gif of the redemption element.
Issues: coupon code persists in text field when redeemed, and need a way to add AJAX callbacks to be executed.
Comment #6
mglaman