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.

CommentFileSizeAuthor
#4 commerce2x-coupon-redeem-update.gif85.78 KBmglaman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs work
Related issues: +#2855815: Add custom coupon storage, provide loadByCode method.

https://github.com/drupalcommerce/commerce/pull/651

Element up. Not tested and no tests.

mglaman’s picture

Status: Needs work » Needs review

PR 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.

mglaman’s picture

Here'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.

  • mglaman authored ea01f37 on 8.x-2.x
    Issue #2855762 by mglaman: Create a coupon redemption element
    
    
mglaman’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.