First off, this is an awesome module.
I have been working on this module to get it working for a client that needs it. Unfortunately, their products are best displayed with Attributes that modify the price and show how the customer wants it delivered (their products are educational courses). But only some attribute options should be discounted. When trying to `Filter by SKU`, only the base product's SKU would show up and none of the SKUs set by attribute adjustments; this was a bit troubling. So, in turn, I cracked open the module and admin.inc files and proceed to make it work for my client. Then afterwards, I sat down and went through the all relevant code and very finely corrected it to work as it should with attribute adjustments.
The code I changed has been over-commented and usually looks like...
// BEGIN MARCUS EDIT (<DATE>)
[code ...]
// END MARCUS EDITI wrote this before the 2010/08/24 dev update and it would be really easy if I didn't have to manually change any future updates, so if you (maintainers) could review it and possible implement it (or something just as effective) in the next update it would be much appreciated.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 900010-uc_discounts_alt-filtered-by-sku-additional2.patch | 1.21 KB | elc |
| #14 | 900010-uc_discounts_alt-filtered-by-sku-additional.patch | 982 bytes | elc |
| #13 | 900010-uc_discounts_alt-filtered-by-sku.patch | 27.37 KB | elc |
| #4 | uc_discounts_alt.zip | 61.32 KB | Poieo |
| uc_discounts_alt_proposed_fix_marcus.tar_.gz | 21.11 KB | nerdacus |
Comments
Comment #1
nerdacus commented*bump*
I changed category, priority and status because I feel this is a major bug, since it is supposed to 'Filter by SKU', but what is the point if it does not acknowledge the SKUs created by attibutes (an optional core module).
Comment #2
Poieo commentedI've test these changes on the latest release and it works as expected.
This is a much needed feature. Unfortunately, it will never get included unless someone provides a patch against the latest release...
Comment #3
schackattack commented@Poieo: how did you manage to do that --> test it against the latest release?
Comment #4
Poieo commented@schackattack - Basically, I went through the attachment marcus provided line by line and moved his code into the latest release of the module.
I'm attaching the version of the module I'm using which is the 6.x-2.0 release with marcus's changes. If someone can role a patch, maybe we can get it committed.
Comment #5
schackattack commentedThanks a lot! Works like a charm. This really should be patched and submitted. I think it's the only available option right now to offer discounts based on alternative skus, since the uc discount framework module doesn't work properly with the newest release of uc. Unfortunately I haven't learned to patch properly yet. :-)
Comment #6
tanjerine commentedThis worked. Thank you. I did the same thing as #4 ... manually applied the patch.
Comment #7
msielskiLooks like 2.1 released on March 29th without this patch. Has anyone manually applied these changes to 2.1 yet? I am going to attempt to construct a patch against 2.1.
Comment #8
jerry commentedSubscribing.
Comment #9
msielski2.1 introduced some new code that I did not have time to get familiar with, but needs similar patching done to it.
I ended up using 6.x-2.0 with the patch in comment #4 since I don't need the new features which 2.1 adds. This works really well and I'd love to see this become part of the module.
Comment #10
jrust commentedIf someone can roll this is a patch I'd be happy to apply it.
Comment #11
FranCarstens commentedI notice this is not in the latest dev. What's the latest on this?
Comment #12
jrust commentedStill awaiting an actual patch.
Comment #13
elc commentedo.O
So how many people manually added the changes and then didn't submit the results back?
Here's the patch, relative to the current HEAD, which at present seems to be the 6.x-2.4 version. I didn't get an notification of a new version and I'm thinking it's because the .info files had "6.x-2.x-dev" or "6.x-2.0" version left overs in them commited to the repository. This patch removes them too.
For those how don't know how to patch .. this is how it's done in a very simple way. There are more complicated way to go.
Apply to git HEAD fa013d5579f82d63797379c26b4340f540aacb59 with
There were a few things wrong with the code as supplied, and I had to change some parts because they no longer matched the logic at all. There was even the rather major bug that it required uc_attributes to be installed and would throw errors without it.
This patch also fixes a bug in the saving of SKU qualification filters.
Full patch log:
Issue #900010 by ELC: Discounts filtered by SKU, attribute adjustments fix.
Adjust admin.inc to pull all SKUs out.
Make admin.inc changes contingent on uc_attribute being installed.
Add remainder of workings to get SKU adjustments to work.
Make .module file check for uc_attribute.
Some semi-related, and completely unrelated things changed in this patch too.
Fix typo in uc_discounts_form_submit that prevented SKUs from required products being saved properly.
Also swapped a few "" to ''. Needs wholesale change throughout the code.
Removed erroneous version and other related variables from .info files
Remove defunct .cvsignore file.
Removed all the CVS Id tags from files.
Comment #14
elc commentedSorry, add this one on too, perhaps as an amend to the last one :P I left a marker in the code so I could search back to it quickly and see that the correct module was being loaded.
Comment #15
elc commented*sheepish grin*
Found some more debugging code I added in that needs to be removed with this additional, additional patch. This one is actually sequential after #1314744: [patch] Use of more than one coupon of same discount for fixed price off.
Comment #16
jastylr commentedJust wondering if this is something that will make it into an official release any time soon. I tried to run the patch but as a noobie when it comes to doing that, I don't believe it went as planned. I used Netbeans to do it and got a message saying that it was partially patched.
Going into the admin page for the discounts, I saw that I can now select an alternate SKU to apply the discounts to based on attribute adjustments but it didn't appear to actually work. Perhaps I'm missing some other piece of the puzzle?
I have a product with several attributes, one of which is an age field. I want to provide a discount of $5 off each item where the age is older than 12 years and cart quantity is 10 or greater. I have setup an alternate SKU for the 12 and under age attribute leaving all other age attributes set to the default product SKU.
In the discounts admin page, I setup the discount to qualify with a minimum quantity of 10 with a fixed amount off of $5 and filter by the default SKU only. The quantity of 10 or more discount works fine but does not take into account the SKU. It simply applies the discount when 10 or more of the product are added to the cart.
To test, I added a quantity of 9 products where the age attribute was set to 18 years old. This attribute would get the default SKU as set in the "Adjustments" section of the product. I then added a single additional product to the cart where the age attribute was set to 12 and under. This attribute uses a different SKU than the one setup to apply for the discount.
When added to the cart, the discount still gets applied as there are 10 items in the cart but it should not since one of the products has a different SKU based on the age attribute.
Am I doing this correctly?
Thanks in advance!
Comment #17
jastylr commentedWent through and applied the patch manually and everything is good now. Works like I would expect.
It would still be nice to see this in an official release.
Comment #18
elc commentedDid you also include the patch from #1314744: [patch] Use of more than one coupon of same discount for fixed price off prior to attempting to add this patch? I needed both of them so the patches are intertwined.
I'm using this patched version in a production site so perhaps I should approach the module maintainer to see if could help. I've also got a companion module that adds some extra useful stuff which would be better to be included.
This patch has been sitting around for ... a while.
Comment #19
occucopy commentedWow, this is a much-needed bug in the core. Is there any way to get a roll/port of this for the D7 port here?: http://drupal.org/node/1035264#comment-5315538
Comment #20
stewart.adam commentedThis patch works well, however there are two problems:
tl;dr: Always match using "Filter by SKU" and just select all products in there if necessary.
Comment #21
stewart.adam commentedFurthermore, this patch seems to move the call of this line:
into a conditional block that is only executed when filter by SKU is set. The result is that determining required product IDs is broken for all non-SKU based filters.
Comment #22
hockey2112 commentedHow would I go about applying this patch to 6.x-2.4? Is it compatible with that version?