Add option to make coupon code checkout pane collapsible (details)

Created on 9 February 2024, 10 months ago
Updated 29 August 2024, 3 months ago

Problem/Motivation

Allowing users to enter coupon codes often means, it shouldn't be shown too prominent.
Typically, you don't want to frustrate users that don't have a coupon code or make them search for one.

For that reason, it would be very helpul to add a setting to the coupon checkout flow item like they existed in several checkout panes in Drupal 7:

Sth. like:
"Display":

  • Do not show as fieldgroup (Default)
  • Show as non-collapsible fieldgroup
  • Show as collapsible fieldgroup
  • Show as collapsed fieldgroup

Technically, the coupon elements should be wrapped into

"#type" => "details"
"#open" => TRUE / FALSE

or "#type" => "fieldset" wrapper, based on the setting.

Steps to reproduce

Add the coupon element in the checkout flow and step through a checkout. The coupon code is always shown very prominent

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Closed: duplicate

Version

3.0

Component

Discount

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    Does the Commerce team agree? Then we'd be willing to implement this as MR.

  • 🇩🇪Germany Anybody Porta Westfalica

    anybody changed the visibility of the branch 3420415-add-collapsible-option-for-coupon to hidden.

  • 🇩🇪Germany Anybody Porta Westfalica

    anybody changed the visibility of the branch 8.x-2.x to hidden.

  • Merge request !321Add wrapper element open setting for coupons. → (Open) created by Anybody
  • Merge request !322Add wrapper_element_open setting → (Open) created by Anybody
  • Status changed to Needs review 3 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    I first thought about, if the solution should be more generic (like being able to select the wrapper_element and its state again as it was in Drupal 7), but this seems to be very specific to the (business) use-case on coupons. You typically don't want to nudge people looking for coupons (less revenue), but if they have a coupon, they should be able to enter it. This is what now the second client in a row asked for and it's now possible.

    The default and fallback is an open details container (that was a container) before.

    Please review.

  • Pipeline finished with Success
    3 months ago
    Total: 573s
    #267789
  • Pipeline finished with Failed
    3 months ago
    Total: 831s
    #267790
  • 🇩🇪Germany Anybody Porta Westfalica

    anybody changed the visibility of the branch 3.0.x to hidden.

  • Pipeline finished with Canceled
    3 months ago
    #267819
  • Pipeline finished with Canceled
    3 months ago
    Total: 551s
    #267820
  • Pipeline finished with Canceled
    3 months ago
    Total: 188s
    #267835
  • Pipeline finished with Canceled
    3 months ago
    Total: 160s
    #267837
  • Pipeline finished with Canceled
    3 months ago
    #267838
  • Pipeline finished with Canceled
    3 months ago
    Total: 130s
    #267840
  • Pipeline finished with Canceled
    3 months ago
    Total: 168s
    #267839
  • Pipeline finished with Success
    3 months ago
    Total: 491s
    #267842
  • Pipeline finished with Success
    3 months ago
    Total: 550s
    #267843
  • Pipeline finished with Success
    3 months ago
    Total: 532s
    #267891
  • Pipeline finished with Success
    3 months ago
    Total: 549s
    #267890
  • 🇮🇱Israel jsacksick

    I wonder if we shouldn't expose a setting for each pane that allows overriding the default instead... So basically the following:

      /**
       * {@inheritdoc}
       */
      public function getWrapperElement() {
        return $this->pluginDefinition['wrapper_element'];
      }
    

    would first look for a wrapper element in the configuration, and then fallback to the plugin definition.
    Something like:

      /**
       * {@inheritdoc}
       */
      public function getWrapperElement() {
        return $this->configuration['wrapper_element'] ?? $this->pluginDefinition['wrapper_element'];
      }
    
  • 🇩🇪Germany Anybody Porta Westfalica

    @jsacksick yeah as written in in #6 I thought about the same and I'm not sure if it's really needed for many other panes (like we had in D7). I'm absolutely not against it, but for coupons it's an important user-/business-focused functionality, while for others it might be nice to have edge-case.

    So my feeling is that this should go in for coupons asap and we could discuss a general solution in the future as follow-up to not block this?

    Do you know why the D7 setting was not kept?
    And yes, I think basically container and details are most important, while we'd also have to add a setting for the default open state then for the containers with an #open attribute.

  • 🇮🇱Israel jsacksick

    So my feeling is that this should go in for coupons asap and we could discuss a general solution in the future as follow-up to not block this?

    Not sure it has to go ASAP, remember that you can easily override this from your project...
    Also you're changing the default wrapper, without an option for existing sites to opt out, meaning theming is potentially going to break without notice.

    Also, instead of exposing an extra setting for determining whether the "details" should be opened, we could probably copy the Webform approach:

     'header' => $this->t('Header'),
          'fieldset' => $this->t('Fieldset'),
          'details' => $this->t('Details (opened)'),
          'details-closed' => $this->t('Details (closed)'),
          'container' => $this->t('Container (no title)'),
  • 🇮🇱Israel jsacksick

    Do you know why the D7 setting was not kept?

    Honestly, no idea :).

  • 🇮🇱Israel jsacksick

    Opened Allow customizing the wrapper element and the display label for checkout panes Needs review which implements a more generic approach to this.

  • Status changed to Closed: duplicate 3 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Closing this in favor of Allow customizing the wrapper element and the display label for checkout panes Needs review thanks to the great @jsacksick!

  • Pipeline finished with Failed
    2 months ago
    Total: 421s
    #288256
  • Pipeline finished with Failed
    2 months ago
    Total: 456s
    #288271
  • Pipeline finished with Canceled
    2 months ago
    Total: 466s
    #288286
  • Pipeline finished with Canceled
    2 months ago
    Total: 522s
    #288294
  • Pipeline finished with Failed
    2 months ago
    Total: 806s
    #288302
  • Pipeline finished with Failed
    2 months ago
    Total: 121s
    #288334
  • Pipeline finished with Success
    2 months ago
    Total: 399s
    #288336
  • Pipeline finished with Skipped
    2 months ago
    #288345
  • Pipeline finished with Skipped
    2 months ago
    #288390
  • Pipeline finished with Skipped
    2 months ago
    #288397
Production build 0.71.5 2024