Problem/Motivation

My client wants to offer a discount off each qualifying item, but not the first item.

Proposed resolution

This simple patch adds a new discount type, "Fixed amount off per qualifying item except first".

Remaining tasks

It may need additional logic to ensure a minimum quantity of at least 2. Right now, you need to set that minimum quantity manually.

User interface changes

The new discount type appears on the "edit discount" screen.

API changes

None.

(Patch to follow.)

CommentFileSizeAuthor
#10 uc_discounts_alt.zip84.63 KBphilsward
#5 uc_discounts_alt_qualifying_except_first_d7.patch3.19 KBAnonymous (not verified)
#4 uc_discounts_alt_qualifying_except_first_d7.patch0 bytesAnonymous (not verified)
#2 add-discount-type-except-first-1285404.patch1.66 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jrust’s picture

I wonder if this sort of (relatively) custom need wouldn't be better handled using the hook_uc_discount() and then putting up the recipe in docs or something?

Anonymous’s picture

Here's the patch. It's against what I got with a "git clone" -- might be the wrong version?

Thanks for the quick response. I'll check out hook_uc_discount().

Anonymous’s picture

Hmm, the "times applied" in "this discount was applied X times" seems to be off now. Not sure what I did wrong there.

Anonymous’s picture

Version: 6.x-2.3 » 7.x-2.0-alpha1
Issue summary: View changes
FileSize
0 bytes

Upgrading a site to D7, so I include the patch here. Note that this patch replaces the "qualifying items" with this custom behavior. (It defines the new constant as 4 and the old constant as 6.) You can easily change this back, though. I did it this way to preserve the data on my site (as I think I'll be the only one using this patch.)

I did look at hook_uc_discount, but it does not seem to expose how many times the discount is being applied on a particular order, so it won't work here.

Anonymous’s picture

FileSize
3.19 KB

Let me try that patch again.

radioflyer’s picture

Thank you for this patch. It's exactly what I need. Can the most recent version of this patch be applied to 7.x-2.0-alpha3, or do you recommend reverting back to alpha1 if this functionality is required?

tinker’s picture

Status: Active » Needs work

@srfarnsworth, This patch will not apply to any releases after 7.x-2.0-alpha1.
@all, if you want this included in module:
- Need to be re-rolled against 7.x-2.0-dev
- Constants DISCOUNT_TYPE_FIXED_AMOUNT_OFF_PER_QUALIFYING_ITEM should remain as 4 and new DISCOUNT_TYPE_FIXED_AMOUNT_OFF_PER_QUALIFYING_ITEM_EXCEPT_FIRST should be 6 to ensure backwards compatibility.
- Messages should not be changed as they apply to all discounts - @times_applied should be included and correctly calculated.

When/if new patch is provided set status to "Needs review". Others will then need to test to make sure this addition does not have any effect on existing discounts that do not use it and it works properly for new discount type. Once reviewed by at least 3 people it can be set "Reviewed and Tested" and I will look at it again.

philsward’s picture

Too bad this hasn't gained traction... I need this exact approach.

First item has shipping cost built in. Subsequent items up to a certain qty, can ship in the exact same box, making the subsequent shipping irrelevant.

This should be extended though to deal with a "between" qty.

Between 1 - 4, apply discount for qty 2, 3 and 4. Start over if qty is 5 and goes up in multiples of the between amount.

philsward’s picture

I had someone add this functionality to Disc. Alt if anyone is interested. At this point, there isn't a "patch" for the changes but I "might" be able to get ahold of one? I think there were 3 or 4 (maybe more) files that were altered in order to pull it off. The change adds 2 new columns to the DB to store the data for the scenario of Discount for items after X. It isn't limited to the first item. You set the max number in the batch, say 6, then discount 4 after the first 2. This would allow someone to have a shopping cart setup where a customer purchases 2 items at full price, then gets a discount for 3,4,5 and 6. After 6, it resets again.

So far it's been working well for me with the limited testing I've done. If no one is opposed, I can dump the entire module into a zip and upload it for someone to extract and pick apart. Creating patches is beyond my ability unless I contact the developer and request one. Just easier for me to upload the zip.

philsward’s picture

FileSize
84.63 KB

Attaching full patched version with "Discount off of first (x) items". Sorry for not applying an official patch.