There's a UX problem right now with discounts defaulting to being active. Creating a discount is a fairly complex task that requires some testing and potential fiddling around to get right, especially if you add in other modules like Commerce Coupon or the need for editorial review. Having them default to active means as soon as they're first saved, they're now automatically applied to any order possibly being placed on the site.

One way to cut down accidental discounts would be to make all discounts disabled by default. This could create the opposite UX problem of people wondering how to quickly create new discounts that are active immediately (i.e. without having to find and toggle the status property), but this could be resolved by the addition of a new button or a drop button such as D8 uses to "Save and publish" or "Save unpublished" a new piece of content.

Any other thoughts?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama created an issue. See original summary.

jkuma’s picture

Assigned: Unassigned » jkuma
Status: Active » Needs review

Hello rszrama,

I totally agree with you, working on my last client project made me realize that we need to expose extra options to prevent direct publishing of a discount.

From my perspective, adding submit buttons such as "Save and publish" and "Save unpublished" seams to be a good start. If we are moving to that direction, we also want to git rid of "enable/disable" dropdown list because the action buttons will take care of that. Moreover, it would be nice to display the current discount status somewhere in the discount form (i mean, the discount edition form).

I'm assigning this issue to myself, will propose a patch soon.

jkuma’s picture

Status: Needs review » Needs work
rszrama’s picture

That's awesome, thanks Jonathan!

jkuma’s picture

Status: Needs work » Needs review
Issue tags: +ui
FileSize
3.08 KB

Hello guys,

Please find attached a first attempt to tackle this issue. I've updated both css and sass files (I'm not sure the sass files are still maintained).

Status: Needs review » Needs work

The last submitted patch, 5: commerce_discount-publishing_actions-2610612-5.patch, failed testing.

jkuma’s picture

The testing has failed, i'm updating the tests (the submit button id/name has changed).

Let me work on that.

@maintainers: In the meantime, may you test the new submit buttons and tell me what you think ?

jkuma’s picture

Status: Needs work » Needs review
FileSize
5.43 KB

Hello ryan,

I've updated my commit according to latest UI changes (the vertical tabs). The discount status is now clearly shown at page top and so i've removed the discount status options from the vertical tabs. The tests have normally been fixed, i'm encountering some troubles to run discount unit tests on my local machine.

Status: Needs review » Needs work

The last submitted patch, 8: commerce_discount-publishing_actions-2610612-8.patch, failed testing.

jkuma’s picture

Status: Needs work » Needs review
FileSize
9.83 KB

New patch that aims to fix up unit tests.

jkuma’s picture

Assigned: jkuma » Unassigned
joelpittet’s picture

Component: Code » User interface
Issue tags: -ui +commerce-sprint

Pulling strings, don't mind me...

joelpittet’s picture

  1. +++ b/includes/commerce_discount.admin.inc
    @@ -288,10 +281,19 @@ function commerce_discount_form($form, &$form_state, CommerceDiscount $commerce_
    +    '#value' => t('Save unpublished'),
    

    This sounds a bit like it will leave the original discount live and save a draft, no? Maybe 'Save and unpublish' to be like the other one?

  2. +++ b/sass/commerce_discount.scss
    @@ -7,6 +7,12 @@
    +    width: 180px;
    

    Try to avoid setting fixed widths in the CSS. It will reek a bit of havoc with other admin themes.

rszrama’s picture

Also, re: the unpublish language, we don't really publish / unpublish discounts. We activate / disable them based on the text we use for statuses elsewhere. We should make sure this is consistent.

mglaman’s picture

+++ b/commerce_discount.test
@@ -227,11 +227,10 @@ class CommerceDiscountTest extends CommerceDiscountTestBase {
+    $this->assertFieldById('edit-submit-publish', t('Save and publish'), 'Save discount button is present');
...
+    $this->drupalPost(NULL, array(), t('Save and publish'));

@@ -246,7 +245,7 @@ class CommerceDiscountTest extends CommerceDiscountTestBase {
+    $this->drupalPost(NULL, $values, t('Save and publish'));

@@ -295,8 +294,7 @@ class CommerceDiscountTest extends CommerceDiscountTestBase {
+    $this->assertFieldById('edit-submit-publish', t('Save and publish'), 'Save discount button is present');

@@ -308,7 +306,7 @@ class CommerceDiscountTest extends CommerceDiscountTestBase {
+    $this->drupalPost(NULL, $values, t('Save and publish'));

@@ -321,7 +319,7 @@ class CommerceDiscountTest extends CommerceDiscountTestBase {
+    $this->drupalPost(NULL, $values, t('Save and publish'));

+1 for changing to "Save and activate"

jkuma’s picture

Assigned: Unassigned » jkuma
Status: Needs review » Needs work

Thank you joelpittet, rszrama and mglaman,

I'll refactor the patch according to your observations.

jkuma’s picture

Assigned: jkuma » Unassigned
Status: Needs work » Needs review
FileSize
9.98 KB
3.36 KB

Hey guys,

Here is an another attempt to solve this issue. I updated the action buttons' labels as following :

  • Save and publish => Save and activate
  • Save unpublished => Save and disable

The discount status is displayed on top of the discount page hence the operator/administrator can clearly see discount current status.

mglaman’s picture

Status: Needs review » Needs work
joelpittet’s picture

Re-roll

mglaman’s picture

+++ b/sass/commerce_discount.scss
@@ -7,6 +7,16 @@
+  #edit-status {
+    background-color: #eee;
+    padding: 10px;
+    display: inline-block;
+
+    label {
+      display: inline;
+    }
+  }
+

Shouldn't this be removed, as it's now part of vertical tabs?

Status: Needs review » Needs work

The last submitted patch, 20: commerce_discount-publishing_actions-2610612-17.patch, failed testing.

The last submitted patch, 20: commerce_discount-publishing_actions-2610612-17.patch, failed testing.

capellic’s picture

Instead of disabling as default, which creates a crazy workflow, how about a configuration option for Discounts in general that says, "only allow access to this discount via a coupon or Giftcard." Something like that?

czigor’s picture

Status: Needs work » Needs review
FileSize
9.86 KB

Just a reroll.