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

Comments

Component:Miscellaneous» Code

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

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

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?

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.

StatusFileSize
new10.55 KB
new14.15 KB

I think this is a bug.

To demonstrate the posted bug see the screenshots.

Screenshot 1; Configured coupons.
coupon listScreenshot 2; Visible coupon on checkout.
coupon on checkout

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

 

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.

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.

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.

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.

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.

Status:Active» Needs review
StatusFileSize
new8.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.

the correct patch