Autofill code when adding a single gift card

Created on 11 November 2020, about 4 years ago
Updated 6 August 2024, 6 months ago

Problem/Motivation

When using the Add giftcard button in the administration UI the administrator is presented with a blank code box. The administrator is required to come up with a hard to guess code.

Steps to reproduce

Go to admin/commerce/giftcards and "Add gift card". The Code text field is blank.

Proposed resolution

Use generateCodes() in the module to pre-fill a generated code in the form.

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @DiDebru could you turn this into a MR please?

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    MR from #6 please proceed with that!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • Pipeline finished with Failed
    3 months ago
    Total: 257s
    #324600
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    For some reason the MR removed the required attribute for the code field on the giftcard entity. This has been reversed.
    Also fixed a phpcs error.

  • Pipeline finished with Failed
    3 months ago
    #324616
  • Pipeline finished with Failed
    3 months ago
    Total: 367s
    #324736
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Tested MR and can confirm it works. Seems ready to commit.

  • Pipeline finished with Failed
    3 months ago
    Total: 242s
    #325504
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I have no objections to merge this, if you say it's fine @rhovland!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @rhovland thought about this again. Should we make this a setting maybe? There might be different use-cases. Of course that could also be done later, if it's an edge-case... I'm unsure.

    Next we should focus on fixing the tests in πŸ› Fix tests Active . Hope to find some more time soon...

  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Providing a default value following the rules for the giftcard type seems pretty straight forward to me. If someone wants to enter a custom code they replace the default value in the text box.

    If this was a setting, where would it be configured?

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @rhovland thanks. Yeah I'm just not totally sure if the default value doesn't potentially confuse users, but I'm not against it. Then perhaps add a short sentence to the description like:
    "The field was prefilled with an auto-generated code, that can be adjusted, if needed." (Please improve, I'm not a native speaker)

    If you disagree, feel free to merge this, and we'll see what happens in the future, but I think a short explanation wouldn't do any harm?
    If it was a setting, it should go into global settings page of commerce_giftcard, I think. But yeah might be too much.

Production build 0.71.5 2024