Project:Ubercart Discounts (Alternative)
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:leon.nk
Status:postponed (maintainer needs more info)

Issue Summary

Is it possible to use this module to do something like "1 product costs $100. Buy 4 and get each for $20 off. Buy more than 4 and get the first 4 for $20 off and the rest for $10 off"?

It seems like this is probably a feature request but I wanted to be sure.

Thanks!

Comments

#1

subscribing....

#2

I heard of someone who was able to implement this without code using a combination of multiple discounts in roughly the following way:
Suppose the product costs $10 and the discount is 1st 4 products are $10 each and after that are $8 each.

Create one discount requiring 5 products to take effect, discounting $2 off each. Create a second discount that "discounts" $-2 off with a quantity of 4, applicable 4 times. This second discount offsets the discount applied to the first 4 products in the first discount. Due to the range of product combinations possible in a cart, this solution will probably result in undesired behavior at some point.

#3

I need to do this as well, I want one rule to handle multiple conditions and discount amounts.

In my case, I will always be using the same qualification and discount type (e.g. it would be buy 10 get 10%, buy 25 get 15%, buy 100 get 25% off).

I was thinking of perhaps tweaking the module to allow for multiple entries in each field, separated by commas. I could then use the php explode function to put these in the array, and then match the discount amounts with the qualifications by index.

#4

ezra-g,

I've enabled multiple discounts and qualifying amounts to be placed. This is done by separating values with commas in the textfields.

So when creating a discount you could have a qualifying amount of 5,10,15
and then in discount amount you could have 0.10,0.15,0.20

There is validation in place to make sure that there are the correct number of amounts and they don't overlap.
The values are then serialized and stored in the same table.

Would you be interested in committing this patch? If so I could provide an update function (as the table field types need to be changed).

Thanks

Leon

#5

It could be useful to have the ability of specifying for how many items this discount applies.

Right now the module allows specifying the quantity after which the discount applies, but the discount is either fixed price, or fixed price for all qualifying items. It would be useful if it was possible to say fixed price for a hardcoded number of items.

So if you have 4 items at regular price, and from items 5-10 you want to have a discount, and the customer purchases 10 items, this option would allow the discount to be applied to a hardcoded number of 6 items (NOT 10 items, which is the current behavior).

I need to use this feature.

#6

Or perhaps provide tokens that allow us to manually compute the fixed price. If for example the number of items ordered was available, one could then manually write the computation for a tiered discount.

e.g. when buying 6 items, and wanting to discount two of them for $10 each, you could write:
(%quantity-4)*10

This would work with any number of iteams (5-10).

#7

Leon,

I need your patch, or simply your code and table changes. This solves a huge issue for me where I want to replace the old functionality of uc_discounts that is easier your way vs. conditional actions discounts framework way. Brilliant. Thanks in advance.

#8

Found this patch, which very seriously needs to be commited into 2x dev release, making list of patches that should be rolled into 2x-dev release
http://drupal.org/node/429128

#9

Hi Red Hat Matt,

I've created those patches for you, (there is no update function so you will need to reinstall the module, or edit the table yourself).

Let me know how it goes and if you get any problems.

Thanks
Leon

AttachmentSize
uc_discounts_alt_tiers_patches.zip 4.29 KB

#10

Well, which patches did you create ? Are they the ones from:

http://drupal.org/node/429128

?? Because if they are, the comments on the patches in that link (including comments from redhatmatt) indicate that the patches don't work.

Or did you create patches from Leon ?

Can you clarify this please ? I am willing to try a patch for this.

#11

It seems to be Leon's patch...

#12

It's a patch aganist 6.x-1.0, while it seems I'm running 6.x-2.0. The project recommends the 6.x-2.x branch. Thus I can't use Leon's patch.

#13

mkmk,

I'll try and figure out what's up and let you know what I did, and if it works how to use it.

#14

mkmk and leon,

had not realized this was for the 1x version, that is a bummer as 2x is what is to be supported, thank you leon... at least it provides direction.

#15

I need this feature.

I tried to merge the patch so that it applies against 6.x-2.0. I am attaching a copy.

However, trying to run install the module results in the entire site getting a blank screen. This is resolved by moving that module out of the modules/ directory and restoring the original 6.x-2.0 module.

I don't know how to debug this. Could someone else have a look ?

AttachmentSize
uc_discounts_broken.tar_.gz 2.88 KB

#16

Version:6.x-1.0-beta33» 6.x-2.x-dev
Category:support request» feature request
Assigned to:Anonymous» leon.nk
Status:active» needs review

The patch was for the 6.x-2.0 version (revisions and module versions are different in case that was causing the confusion).

There seems to have been quite a few revisions made recently, so you both probably don't have the same copy as what I made the patch for (which at the time was the latest one from HEAD).

Here's a new set of patches, which have cleaner code, and are for the current latest revision which is module revision 1.3. This has not yet been updated on the module page, but you can download the copy through the CVS repository (there's a link to it on the module page).

I haven't had enough time to properly test this, so any bugs relating to this patch please report them back here.

Thanks
Leon

AttachmentSize
uc_discounts_alt_tier_patches_2.3.zip 4.26 KB

#17

Leon, thanks for looking into this.

The patch just posted does not apply against the latest 6.x-2.x version available for download. There does not seem to be a 6.x-2.0 version available; just 6.x-2.x (unless I am missing something)

# patch --dry-run -p1 < /tmp/ucnew/uc_discounts_alt_tier_patches_2.3/uc_discounts.admin.inc.patch
patching file uc_discounts.admin.inc
Hunk #1 FAILED at 113.
Hunk #2 FAILED at 127.
Hunk #3 FAILED at 169.
Hunk #4 FAILED at 176.
Hunk #5 succeeded at 624 (offset 92 lines).
Hunk #6 FAILED at 752.
5 out of 6 hunks FAILED -- saving rejects to file uc_discounts.admin.inc.rej

# patch --dry-run -p1 < /tmp/ucnew/uc_discounts_alt_tier_patches_2.3/uc_discounts.module.patch
patching file uc_discounts.module
Hunk #1 FAILED at 579.
Hunk #2 succeeded at 1320 (offset 122 lines).
Hunk #3 succeeded at 1336 (offset 122 lines).
Hunk #4 succeeded at 1375 (offset 122 lines).
Hunk #5 FAILED at 1404.
Hunk #6 succeeded at 1412 (offset 122 lines).
Hunk #7 succeeded at 1500 (offset 122 lines).
Hunk #8 succeeded at 1520 (offset 122 lines).
2 out of 8 hunks FAILED -- saving rejects to file uc_discounts.module.rej

#18

>The patch was for the 6.x-2.0 version (revisions and module versions are different in case that was causing the confusion).

> which is module revision 1.3.

I am still confused by these two statements.

The versions I see available are:

http://ftp.drupal.org/files/projects/uc_discounts_alt-6.x-2.x-dev.tar.gz
http://ftp.drupal.org/files/projects/uc_discounts_alt-6.x-1.0-beta36.tar.gz

The patch does not apply against:

http://ftp.drupal.org/files/projects/uc_discounts_alt-6.x-2.x-dev.tar.gz

Is it intented to be applied against:

http://ftp.drupal.org/files/projects/uc_discounts_alt-6.x-1.0-beta36.tar.gz

??

#19

You need the version that's on the CVS repository (as it hasn't been updated on ftp.drupal.org yet), which you can find at http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/uc_discount...

#20

I was able to get the version from CVS and apply the patch cleanly.

One bug I'm seeing is that if I manage to create a discount with no errors (and that currently happens only if I don't use any comma-separated values), the discount does not even show up. in /admin/store/settings/uc_discounts. I see a message that reads:

" settings have been saved."

But there is no such discount listed.

#21

I also get the error message:

"The discount amounts were in an incorrect order"

When I choose "Qualifying amount": 5,6,7

and then "Discount amount": 95,95,95

for a "Discount Type" of "Fixed amount off".

#22

Oh, I think in this case the "Discount amount" should be something like: 95,190,285. Setting it to that allows creating the discount.

But the discounts do not seem to be stored.

mysql> select * from uc_discounts;
Empty set (0.00 sec)

Even though there are entries in table uc_discounts_codes.

#23

It seems that the query produced in function uc_discounts_insert() is:

INSERT INTO {uc_discounts}(name,short_description,description,qualifying_type,qualifying_amount,has_qualifying_amount_max,qualifying_amount_max,discount_type,discount_amount,requires_code,filter_type,has_role_filter,requires_single_product_to_qualify,max_times_applied,can_be_combined_with_other_discounts,max_uses,max_uses_per_user,max_uses_per_code,has_expiration,expiration,is_published,weight,insert_timestamp) VALUES('%s','%s','%s',%d,'%s',%d,%f,%d,'%s',%d,%d,%d,%d,'%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)

So... there are 24 values expected to be inserted, BUT the call to db_query() passes the query and 23 values. One less value is passed -- or there's one too many format string qualifiers.

This also shows up in the site logs:

Column count doesn't match value count at row 1 query: INSERT INTO uc_discounts(name,short_description,description,qualifying_type,qualifying_ ...

#24

I believe the problem is in:

function get_uc_discounts_column_printf_wildcards() {
return array("'%s'", "'%s'", "'%s'", "%d",
"'%s'", "%d", "%f", "%d",
"'%s'", "%d", "%d", "%d",
"%d ", "'%s'", "%d", "%d", "%d",
"%d", "%d", "%d", "%d",
"%d", "%d",
);
}

It should be:

function get_uc_discounts_column_printf_wildcards() {
return array("'%s'", "'%s'", "'%s'", "%d",
"'%s'", "%d", "%f", "%d",
"'%s'", "%d", "%d", "%d",
"'%s'", "%d", "%d", "%d",
"%d", "%d", "%d", "%d",
"%d", "%d",
);
}

... at least, this change works for me.

#25

No... that's not right. It does not work for me. I can save a discount, but the "Discount amount" is not saved.

#26

mkmk, glad you got the patch working...

Did you reinstall the module?

It needs a reinstall because the mysql tables need altering (this was mentioned in #9). So if not this is probably why the discounts are not being saved.

As for the error message about the discount amounts being in the wrong order. Each tier has to be greater than the previous, otherwise I'm assuming a mistake has been made.

For your discount of...
qualifying amount: 5,6,7
discount amount: 95,95,95

You don't need to use tiers for this. The qualifying amount should just be 5 and discount amount 95.

#27

It needs a reinstall because the mysql tables need altering

Adding a new feature shouldn't require a reinstall of an existing modules. That's why we have hook_update_N.

Also, to make the patch easier to review, could you re-roll it as a single patch rather than 3 separate files?

I hate to introduce potentially overlapping work, but here is a patch that works now and has been in use on a project for many months. It allows you to have a discount to apply only on the Nth item in a cart. So, you could make a discount that only applies after you have 20 of one item or 20 total items in the cart. You could create several of these discounts to create multiple discount tiers. This may require a bit of additional processing to get it to work with all discount types, but it's 80% of the way there, if not further for additional discount types.

AttachmentSize
540080.patch 6.95 KB

#28

Here's a preview of what it looks like on the admin interface:
Only local images are allowed.

#29

Hi Ezra-g,

I can't see the preview of the admin interface on #28.

From what I can gather, it does not sound like this overlaps with my patch. You still need to create separate discount rates for each tier level, and this is exactly what I was trying to get away from. My current project is a store with around 20 different discount rates, each with around 4 tiers. Setting these up individually would be a nightmare.

Here's a new patch, all in one, with an update function.

The only issue with the update function is that I've had to use an ALTER sql query as apposed to db_change_field(). The reason being db_change_field removes the field first, meaning any previous discount_amounts are lost.

Mkmk... apply the new patch and then update the module through update.php, you should then be able to save the discount tiers.

AttachmentSize
uc_discounts_alt_tiers.patch.txt 7.66 KB

#30

I did not get the patch working. It does not work for me.

I did reinstall the module, but that did not help. As I mentioned in comment #23, the number of fields stored is not right.

I'll try the new patch in comment #29 and see how it works.

#31

The patch in comment #29 does not work either. Trying to add a discount reports:

"Discount amount must be integer, decimal or percentage."

It seems that this patch has not updated uc_discounts.admin.inc.

#32

I'd like to see a response to my comment #23.

#33

Sorry mkmk, missed those posts (looks as though they were posted while I was still writing #29).

You are right, the columns don't match up. Another issue of the many revisions to this module.

I would really like to push for a big clean up of this module, the uc_discounts_insert and uc_discounts_update functions are incredibly messy. Was pretty tedious having to count through each table column and check manually for the correct data types. It would be much simpler to use drupal_write_record(). Anyway that's a separate issue.

A new patch made, which I've had a bit of time to test myself now. Hopefully this should work for you.

Thanks
Leon

AttachmentSize
uc_discounts_alt_tiers.patch.txt 14.25 KB

#34

Already discovered a problem myself.

New patch uploaded...

AttachmentSize
uc_discounts_alt_tiers.patch.txt 14.25 KB

#35

The new patch from comment #34 reports:

# patch --dry-run -p0 < /tmp/uc_discounts_alt_tiers.patch_0_0.txt
patching file uc_discounts/uc_discounts.install
patching file uc_discounts/uc_discounts.admin.inc
Hunk #4 FAILED at 533.
1 out of 7 hunks FAILED -- saving rejects to file uc_discounts/uc_discounts.admin.inc.rej
patching file uc_discounts/uc_discounts.module

#36

This is getting a tad tedious. Not quite sure what is going wrong because I'm creating the patches using the same versions from CVS. Maybe it's my IDE that's doing something weird.

Anyway, this one I've tested by patching myself and it works.

AttachmentSize
uc_discounts_alt_tiers.patch.txt 13.8 KB

#37

This patch works. Thank you Leon!

One thing I noticed is that the textbox for the Discount Amount has a maximum limit of characters it can accept. I wonder if there's a way to remove that limit.

For example, I need to provide a tiered discount for over 100 items.

#38

It seems that this problem can be corrected by defining something like:

"#maxlength" => 8192,

in the definition of $form["discount_amount"] in uc_discounts.admin.inc. I'd recommend this to be included in the patch.

#39

The same should be applied to the definition of $form["qualifying_amount"]

This is great!

#40

Actually, if a large amount of values is entered for e.g. the qualifying_amount (e.g. over 1000 values), the data are not stored in the database at all.

An equation like the one described in comment #6 would be a better approach. Still, this patch is definitely better than nothing and should work for most cases.

Leon, thank you so much for all the help.

Ezra-g, do you have any thoughts ?

#41

Thanks mkmk, I had not tested this with a large number of tiers.

There shouldn't really be a limit to the amount of tiers being saved. I can only think that 1000 values exceeds the limit for the mysql table. Could you possibly send me a private message with those values so I can test it out.

#42

My that is a rather long list you have.

It was just a the table field size being too small to fit all the values.

I've made some amendments for you in this patch. Re-install or update the module.

I've also set it so that when amounts that are longer than 50 characters are entered, the field becomes a textfield.

What I'm not sure about is performance when dealing with these large arrays. I should think it would be fine but let me know if you notice anything.

Thanks

AttachmentSize
uc_discounts_alt_tiers.patch.txt 15.19 KB

#43

To all of the above:

So glad I found this!
Using the 6.x-2.x-dev version (CVS HEAD or downloaded from the project page), I could not get the "Click to calculate discounts" button to produce anything, not even for a simple no-code-required 10% discount on any order (of any products) over 10 items.

Not only does this patch implement my client's needs (i.e. discounts tiered by quantity), it also seems to go a long way in making some of the basics of this module to work. The only version available for download on the project page is 6.x-2.x-dev and this version seems to be in a bad state.

There are still a few glitches remaining, even with the patch (and I'd love to be proven wrong):

o When creating the discount, if you set the Filter Type to anything other than Product Type (i.e Term or SKU), you get the same problem as I had without the patch: no discounts get calculated whatsoever.
o There's also a tickbox "Filter based on roles", which when you tick it no longer brings up a role selection drop-down, but causes an error upon submit instead: "Roles are required because 'Filter based on roles' is checked".
o "Require(s) code" seems to be broken in a similar way.

Still, this gives me something to work with.... And it's not available in uc_coupon!

Thanks again.

#44

Just thought for those who aren't comfortable applying patches, I'd attach the updated module as an installable tar-ball.
Rik

AttachmentSize
uc_discounts_alt.tgz 28.68 KB

#45

RdeBoer,

I had a look at those glitches, and you are right. There's a whole lot of stuff not working on the edit discount page.

I've created a separate issue with a fix for this, as it has nothing to do with the patch or tiered discounts.
http://drupal.org/node/788590

As for the "click to calculate discounts" problem on the checkout page. I can't replicate this, discounts are showing up fine for me.
I would check to see if other line items are working (e.g. shipping, tax). Again though, this is a separate issue.

Thanks
Leon

#46

Hi Leon,
Yes the three glitches are separate -- thanks for parking these in their own threads.
Rik

#47

While loving the functionality of the patch in #42 (complete module in #44), my client wanted something extra (don't clients always ask for more?!).

He wanted a message to pop up to entice a buyer to add items to the cart to reach the next discount tier (see attached image, using Garland theme).

So I thought I'd share the attached module uc_discounts_alt_xt, which achieves this.
It requires no configuration. Just enable and off you go.

I wrote the code as a small new module rather than a "patch to a patch" to reduce coupling and interference between this extra functionality and that of the original patch.

Hope people find it useful.

Rik

AttachmentSize
uc_discounts_alt_xt.jpg 65.92 KB
uc_discounts_alt_xt.tgz 1.38 KB

#48

About #42, for whatever it's worth, the idea of dynamically altering tables scares me.

Will it really be that slow if that field is a LONGTEXT to begin with ? This is for one table, with discounts. How many discounts will there be ? I doubt there will be many. Besides, without performance measurements this is the kind of work that only complicates things.

In any case, I wish all this work on this issue is commited in the repository and a new tested version of this module becomes available so we all know where we stand.

#49

I didn't mean the database field was dynamically changed, what I meant to say was when the list was over 50 chars long the form input on the discount rate screen changed from a textfield to a textarea (so that longer lists could be more easily edited).

The database field is always longtext.

#50

subscribing..

#51

I've rolled an updated patch for this enhancement, which works on the latest dev version (June 11th, 2010) and would love feedback on it.

This patch also adds a few query modifications that allow you to add SKU's put in a product's adjustments fields - so you are no longer limited to selecting products for discount by only the product SKU.

I've only done the briefest testing. Will do more after some sleep.

FYI - this take the js file back a to the original one in #42 because the latest has a few @ symbols which are deprecated in jQuery and caused havoc with my site.

AttachmentSize
sku-tiered.v1.patch.txt 21.9 KB

#52

Tested patch in #51. Works great applied to 6.x-2.x-dev (2010-Jul-11)

I used the following

quantity: 11,25,100
discount: 0.5,1,4.5

Discount applied to all items as expected.

Thank you!

#53

ptoly, glad to see you taking thing further.
Can you explain a bit further what the additional functionality regarding SKU's provides? I think if it's unrelated to the discount tiers (and this thread) then it should be moved into a separate patch (on a separate issue).

Also, it'd be good to stick to Drupal coding standards: http://drupal.org/coding-standards
Running the patch through coder (http://drupal.org/project/coder) will let you know what problems there are (a quick example are the tabs being used instead of spaces).

Thanks
Leon

#54

I dont want to be offtopic but I really like the SKU filter provided by the patch. The only problem is if you want a certain option discounted more on all products you have to manually select each one. It would be nice to have an entire new filter based off global attribute options. I have an official request here: http://drupal.org/node/865520

#55

I second #54, it would be good to have a discount for all of 1 or many kinds of product attributes (global).

For example, I sell a rose product with 3 sizes. I want to get rid of the largest size, now I want all my products to have that size 20% off. Would be easier to do that globally, than selecting each and every sku.

Thank you.

#56

I tried running this patch (and when I say *I* I mean - somebody smarter than I) and got the following error:

***************
*** 1,5 ****
<?php
- //$Id: uc_discounts.admin.inc,v 1.10.2.5 2010/01/08 17:00:21 ezrag Exp $

/**
--- 1,5 ----
<?php
+ //$Id: uc_discounts.admin.inc,v 1.10 2009/08/22 21:30:39 ryangroe Exp $

/**
***************
*** 734,743 ****
else $expiration = 0;

//Set discount_amount
- if (($index = strpos($form_state["values"]["discount_amount"], "%")) !== FALSE)
- $discount_amount = floatval(substr($form_state["values"]["discount_amount"], 0, $index)) / 100;
- }
- else $discount_amount = floatval($form_state["values"]["discount_amount"]);

if (empty($form_state["values"]["discount_id"])) {
//Insert base discount
--- 804,819 ----
else $expiration = 0;

//Set discount_amount
+ // Multiple values patch - todo - need to add this validation for patched version
+ // if ($form_state["values"]["discount_amount"] && (strpos($form_state["values"]["discount_amount"], "%")) !== FALSE)
+ // $discount_amount = floatval(substr($form_state["values"]["discount_amount"], 0, $index)) / 100;
+ }
+ else $discount_amount = serialize($form_state["values"]["discount_amount"]);
+
+ // Multiple values patch
+ $form_state["values"]["discount_amount"] = serialize($form_state["values"]["discount_amount"]);
+ $discount_amount = $form_state["values"]["discount_amount"];
+ $form_state["values"]["qualifying_amount"] = serialize($form_state["values"]["qualifying_amount"]);

if (empty($form_state["values"]["discount_id"])) {
//Insert base discount

Any idea what's going on here? I would REALLY love to get this working as I have a project that needs this functionality badly. I was thrilled to run across the patch and devastated when we couldn't get it to work.

Oh, we ran the patch on the latest (Aug 11) version of the dev. Don't know if that helps.

Information added by drupal.org packaging script on 2010-07-11
version = "6.x-2.x-dev"
core = "6.x"
project = "uc_discounts_alt"
datestamp = "1278836081"

#57

Hi leon,
Sorry to take so long to get back to you.

I put this in this thread because my client needed to be able to offer a shipping discount on the second identical item and this thread starts with a very similar request.

Where this patch diverges is that the discount were to be based on attribute SKUs. So this patch does appear to help 'tiered discounts' with the added benefit of being able to apply them to attribute based SKU's. If you think this would be better suited in another thread I'm fine with that.

Sorry about the coding. I've reconfigured my tools to do things the Drupal way now. :)

#58

Any thoughts on why your patch didn't work for me (as I mentioned above)?

#59

I've adapted the patch from #51 to the most recent Dev version (2010-Aug-16). Try it out and hopefully it works. This patch still needs review before it should be applied to production sites. Test it and give your feedback.

AttachmentSize
uc_discounts_alt-540080-V2.patch 20.72 KB

#60

Oops, went and tried it and found an error. Should be fixed in this patch.

AttachmentSize
uc_discounts_alt-540080-V3.patch 20.72 KB

#61

Fantastic. I'll give it a try asap and give feedback.

#62

The patch works inasmuch as it's not throwing any errors but it doesn't appear to give the added functionality that I was hoping to see - that is the ability to add SKUs from the product adjustments as well as standard project SKU.

Any thoughts? I really appreciate the work you guys are doing on this, btw. I think that these changes are needed and can't wait to see them as part of the module.

#63

As far as I understand all the patch allows you to do is make it so you have have multiple tiers of discounts. So if somebody purchases 10 products it's a $5 discount, 50 products is a $10 discount, etc. Of course that's just one example but as far the the ability to add SKUs from the product adjustments I think that would be a separate issue that I think you should start as it doesn't seem totally related. Unless I'm misunderstanding what you're trying to do of course.

#64

I guess I must have misunderstood comment #57 above where ptoly said "Where this patch diverges is that the discount were to be based on attribute SKUs. So this patch does appear to help 'tiered discounts' with the added benefit of being able to apply them to attribute based SKU's"

I actually found this thread via another thread where the attribute-based SKU discounts were being discussed and a link lead here as this patch was supposed to deal with that. http://drupal.org/node/467184#comment-3204062

#65

Thanks very much for this wonderful enhancement. Just these observations here so far.

Installed and once I got past a glitch it seems to work fine.

In my case, I applied the patches, uploaded the new versions, ran update.php, which reported no updates to do, and observed that quantities and discounts were not saved. I then went in via PHPmyAdmin and changed qualifying_amount and discount_amount fields in uc_discounts table both from float to text, and then all worked fine. I'm not sure why the database update didn't occur correctly here but may be my cockpit error.

I notice that although the shopping cart summary page correctly shows the line items and modified total price, the shopping cart block that shows the total displays the original (undiscounted) total. In my case, with some large percentages off, the shopper looking at only the block might think things are too expensive. (This is as before, I believe, not affected by this patch.)

On the checkout screen, the top box shows undiscounted prices, so one has to scan way down the page before understanding the full price will not be charged. (This is as before, I believe, not affected by this patch.)

Thanks again for providing this. It makes the number of rules far more manageable and it reduces the number of discount lines, a feature my client was very concerned with.

#66

Hi Folks,
I am supremely interested in the functionality listed in #51, further expanded by #60.

However, I'm having trouble getting the right patchable version. Ive *just* learned how to access Drupal CVS using TortoiseCVS. Using TortoiseCVS 'Revision-on-this-date' Ive pulled the revisions listed (June 11th, 2010) and (2010-Aug-16) respectively.
However, all Hunks fail on patch attempt.

If it will help, I am willing to offer testing services for this module and patch to offset the expense of assistance.

#67

With Help (Thanks jestith) I was able to overcome the issue described in http://drupal.org/node/540080#comment-3402048
Though I think Ive discovered a bug in the patch http://drupal.org/node/540080#comment-3346202

Background:
I have base Products that are configured with Adjustment -> Alternate SKUs. These SKUs are used to identify different colors of product.

Use Case:
T-Shirt base Product has 3 Adjustment/Alternate SKUs, 1 for each of the 3 colors, red, green and blue.
I have created a discount using the Filter Type = Filter By SKU. However, it seems this discount does not apply as expected.
Requirement is to give a discount only for purchases of 3 of any single color of T-Shirts; not in combination
3 Red Shirts = discount applies
3 Green Shirts = discount applies
3 Blue Shirts = discount applies
2 Red + 1 Green = discount does not apply

Recreation Steps:
1. Create a Product and setup Alternate SKUs

2. Define a discount with these settings
min quantity = 3
Require Code to activate = false
Qualification by Role = all roles
Require single product sku to qualify = false
Discount Type = percent off - .5
Filter Type = Filter By SKU
SKUs = Select the Alternate SKUs created in step 1. Notice here, the Alternate SKUs are indeed listed in the selection box.

3. Fill the cart appropriately. You will find no discount applied.

4. Edit the discount again and change Filter Type = Product and select the same product as step 1.

5. Repeat step 3. The discount will be applied properly.

For some reason, the mechanism is not respecting the SKU filter when it is applied to Adjustment/Alternate SKUs, even though these very same SKUs are listed within the selection box.

#68

You're more than welcome.

Just to add to the Filter by SKU issue, I note that on my client's system, when I select Filter by SKU, I see only one product rather than the expected long list. I'm not employing any Adjustment/Alternate SKUs, just dealing with plain vanilla SKUs assigned to each product. In my case, I can live without Filter by SKU and just use Filter by Product, but it does seem to have an issue.

#69

Could someone help clarify - is it possible to easily select all SKU's of a particular attribute (like apply discount to all products that are blue?). Or do we still use a multi select field to select all the SKU's individually?

#70

subscribe, would love to see this

#71

Subscribed. Manually applied patch from comment #60 since I am running 6.x-2.x-dev (2010-Aug-24) and wanted to make sure the bits of patched code were not different since the patch was made from a prior build. I am not a developer and don't use CVS or an IDE so I read the patch file visually side-by-side. I also wanted to see how the code was different ... I can mostly *read* PHP but can't *write* it, heh.

This functionality (multiple quantity discount price tiers) is totally critical to my client's site. It has made the difference that allowed us to go live after extensive testing.

The only thing that tripped me up was that I should have uninstalled uc_discounts_alt (using the Modules tab "Uninstall") before applying the patch so the tables were built properly from the get-go with longtext to hold the tiered qualifying amount and tiered discount amounts.

Thanks!!

#72

Status:needs review» postponed (maintainer needs more info)

This issue has become disorganized, and in some cases it's not clear which patch a particular bit of feedback is referring to. I would like to commit one approach from this issue so that further work can happen in new issues.

It's unclear to me what the differences and advantages are to the (apparently 2?) different approaches are to addressing this issue aside from the fact that the patch in #27 involves creating a discount for each tier level, but in #29, leon.nk says "My current project is a store with around 20 different discount rates, each with around 4 tiers. Setting these up individually would be a nightmare." apparently referring to the other patches which I'll call the second approach.

Is there a screenshot of the discount configuration approach for this second approach?

#60, which is apparently a re-roll of the second approach, introduces new coding standards issues (incorrectly formatted conditionals), which is problematic.

My inclination is to re-roll and commit the patch in #27 since I know that it works and am familiar with how it works but I'm open to understanding (ideally with the help of a screenshot) why the other approach is better :).

#73

Also, according to comments #65 and #71, the patch in #60 apparently doesn't properly update the schema.

#74

I think all patches from this module stem from my own (starting on #9 and final version on #42), apart from the one you uploaded ezra-g on #27.
Patches posted by other people are my patch with added features, most of which seem quite unrelated to the topic of this thread, which is to be able to create tiers for discounts within the same rate.

I still don't fully understand patch #27, but here's a screenshot of the interface from my own patch. It has been running on a live store for a couple of months now.

Thanks
Leon

AttachmentSize
discount.gif 25.11 KB

#75

I really appreciate all the work you guys are doing on this. It's exactly what I need right now, as I need to have a multi-tiered quantity discount that will work with other discounts.

I just tried applying the patch in #42 to my site (using 2010-Aug-24 version) and received quite a few FAILED messages. Here's the output from the patch command:
*****************************************************************************
patching file uc_discounts/uc_discounts.install
Hunk #3 FAILED at 485.
1 out of 3 hunks FAILED -- saving rejects to file uc_discounts/uc_discounts.install.rej
patching file uc_discounts/uc_discounts.admin.inc
Hunk #1 FAILED at 114.
Hunk #2 FAILED at 180.
Hunk #3 succeeded at 632 (offset 94 lines).
Hunk #4 succeeded at 614 (offset 6 lines).
Hunk #5 FAILED at 671.
Hunk #6 succeeded at 784 (offset 106 lines).
Hunk #7 succeeded at 716 (offset 7 lines).
3 out of 7 hunks FAILED -- saving rejects to file uc_discounts/uc_discounts.admin.inc.rej
patching file uc_discounts/uc_discounts.module
Hunk #1 FAILED at 579.
Hunk #2 succeeded at 1326 (offset 128 lines).
Hunk #4 succeeded at 1381 (offset 128 lines).
Hunk #5 FAILED at 1410.
Hunk #7 succeeded at 1506 (offset 128 lines).
2 out of 8 hunks FAILED -- saving rejects to file uc_discounts/uc_discounts.module.rej
*****************************************************************************

Applying the patch in #60 worked great, with the exception of the database updates, and the fact that I had to re-edit all previous discount quantity and discount amounts due to the database change.

Now, if there was a way to allow some items to be considered for one discount, but not another. For instance, to offer a free CD with a book purchase, but not count that CD as part of a quantity discount. As it is now, If someone buys a book and 4 CDs, they get a free CD, plus a discount on all 4 CDs rather than just the 3 they need to pay for.

I know, there's ALWAYS something more -- and this is a separate feature request.

Again, thank you everyone for the work you've put into this.

#76

subscribing

#77

ezra-g: to clarify my comment in #71, I had monkeyed with the uc_discounts_alt tables prior to applying the patch in #60. Most likely it was my own fault for messing up the tables. After I (properly) uninstalled uc_discounts_alt, and made sure the tables were in fact gone, I reinstalled with no errors and applied the patch -- again, with no errors.

Thanks!

AttachmentSize
screenshot Part 1 44.7 KB
screenshot Part 2 28.66 KB

#79

#80

It seems our patches need to be updated to work with the new release of the module. I just tried applying the patch from #60, which has been working fine up to this point, and it fails with the new release.

Thanks.