A neat feature would be to have the coupon code pane inactivated when there are no active coupons. This is really a nice-to-have feature and not a must, but the checkout panes get cluttered quite easily when using shipping modules, several payment methods etc. so anything that can reduce clutter when it's not needed would be useful.

The idea is basically that if the are no active coupons, the coupon fieldset should not be visible in checkout

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webmasterkai’s picture

Component: Miscellaneous » Code

I like this idea. It will probably be two weeks before I get around to it.

bradhawkins’s picture

+1 for this. Would also be nice if it could be verified against a coupon's user reference field. In other words, only present if the current user has an active coupon.

quiptime’s picture

Category: feature » bug
Priority: Normal » Critical

Coupon field displayed in checkout if no coupon active still exist.

This makes the module unusable for me.

What is the problem to fix this bug?

pcambra’s picture

Category: bug » feature
Priority: Critical » Normal

I still think that this is a feature request, please check the priority level of issues for further information.

Can we clarify exactly what is this request about? the checkout pane should be aware of the status of the coupons so it should query all coupons to see if there's at least one active for this context?
This would mean not only to query those, but also execute the rules to see if the context is right, seems a little too much to be generic.

Let's open the discussion and define what do we want here.

quiptime’s picture

FileSize
10.55 KB
14.15 KB

I think this is a bug.

To demonstrate the posted bug see the screenshots.

Screenshot 1; Configured coupons.
coupon list

Screenshot 2; Visible coupon on checkout.
coupon on checkout

The situation, seen in the screenshots, is not configurable. If it configurable, please document this.

 

pcambra’s picture

I don't see anything wrong with the screenshots attached, that's working as expected.

Please review again my comment in #4:

The checkout pane should be aware of the status of the coupons so it should query all coupons to see if there's at least one active for this context?
This would mean not only to query those, but also execute the rules to see if the context is right, seems a little too much to be generic.

Not sure if we want to do this, really. You may have thousand of coupons.

quiptime’s picture

First part for a solution.

The checkout pane should be aware of the status of the coupons so it should query all coupons to see if there's at least one active for this context?

It is not necessary to query all the coupons if they are active.

A counter query to the table commerce_coupon gives the answer about the number of active coupons.

If the result 0, it does not display a coupon in the checkout.

Yes, this is generic and should be the first step to decide whether to display a coupon.

For the second part of a solution, mixed active states with many coupons, I have no idea.
This is so due to the fact that I was not employs enough with the code of the module - sorry.

pcambra’s picture

A counter query to the table commerce_coupon gives the answer about the number of active coupons.

This is querying all the coupons. You need to retrieve all to know if a given column has a given value. And that a coupon is active is not the only criteria, it might be no possible to add a coupon to an order even if it's active (coupons binded per product, per user, given date...)

As I said, this is probably not required by most people using coupons and I don't want to add such a overload for just displaying a pane.
At most we could think in adding a setting at pane level with a big warning on this possible performance issue.

quiptime’s picture

It is possible to use an additional summary table. Each action which activates or deactivates a coupon updates this table.

The result of the query from this table is the first decision, whether to display any coupon.
In this variant there are no performance problems. The table has only one entry.

This is only the basic step for a solution. No active coupon -> no coupon display in checkout.

I think, that means the initial post.

pcambra’s picture

It is possible to use an additional summary table. Each action which activates or deactivates a coupon updates this table.

Absolutely not, we don't need that. I'd rather have this enabled/disabled on demand because I'm still thinking this won't be used by everyone.

I'm still wondering myself if you just need the active/not active status or you need the whole rules stuff in there.

I'm up for the setting at checkout pane level let's not overengineer this.

Keeping this as feature request to see if someone can provide a patch for this.

Cristian.Andrei’s picture

Status: Active » Needs review
FileSize
8.97 KB

EDIT : use the patch in comment 12. This one has an extra function which is not used anywhere.

Here's a patch for you guys. I've cooked this up for a live site that I am maintaining and it does the trick.

Use it wisely.

Cristian.Andrei’s picture

millionleaves’s picture

Issue summary: View changes

Can someone confirm if this patch works with v2 of the module?

mdupree’s picture

Minor change to get it to work with version 2.

+++ b/includes/commerce_coupon.checkout_pane.inc
@@ -12,95 +12,110 @@
+    ->propertyCondition('is_active', 1, "=")

change is_active to status for version 2

patch included.

Status: Needs review » Needs work

mdupree’s picture

My Patch failed [#14] due to:
error: commerce_coupon.checkout_pane.inc: No such file or directory
Patch Failed to apply

I am no expert on how these tests perform, If someone could chime in as to why there's no "commerce_coupon.checkout_pane.inc"
and I will do what I can to get this cleaned up.
Thanks

mdupree’s picture

Re trying patch upload because of test failure of patch #14