I'm setting-up Ubercart with "Ubercart Discount Codes" for a client who would like all of the cart line items passed through to PayPal, but according to #330058: PayPal does not receive the coupon-adjusted price this currently isn't possible, because PayPal rejects negative line items.

However, according to the section "Setting Discounts for the Cart" in chapter 7 of the "Website Payments Standard Integration Guide", it is possible to pass discounts on a per-cart or per-item basis.

How involved would it be to add logic to automatically convert negative line items to discounts?

Comments

guypaddock’s picture

Note: I'm referring to the May 2010 revision of the "Website Payments Standard Integration Guide".

guypaddock’s picture

Status: Active » Needs review
StatusFileSize
new773 bytes

Well, it turned out not to be much work at all. The attached patch adds handling for negative line items/discounts.

tr’s picture

Can you post links to the PayPal documentation that says negative line-items are now OK? I programmed a non-Drupal site a few years ago where I had to make extensive use of the PayPal API, and I can tell you that back then it was definitely not allowed and PayPal insisted to me it never would be - they disallowed negative line items for a reason and they weren't going to change. And since PayPal won't even fix bugs (some I know which go back 4 years or more), I would be surprised to find out that they are now allowing negative line items.

guypaddock’s picture

See the Website Payments Standard Integration Guide, page 336, under the section "Setting Discounts for the Cart".

The patch I submitted above doesn't use negative line items -- it converts negative line items in the Ubercart order into discounts on the PayPal side.

pharoz’s picture

Great job, GuyPaddock! I applied both your patches and the Discount line items went through for itemized orders.

Have you mention this patch to the Ubercart core since it's modifying it?

3dloco’s picture

+1 ..this worked for me too! Thank you very much GuyPaddock!

guypaddock’s picture

@pharoz, what do you mean by "mention it to the core"?

pharoz’s picture

@ GuyPaddock, Disregard that. I thought this issue was posted under the ubercart discount module issue tracker for some reason... it's already under the ubercart issue queue.

bsmith451’s picture

This also worked for me !

guypaddock’s picture

Status: Needs review » Reviewed & tested by the community

Changing status -- unless there is an objection?

MBroberg’s picture

It doesn't work for me but I do not have any other discount module enabled, only Ubercart. Is there a second patch or module that is also needed?

The code is not removing or change the negative item in the itemized list.

MBroberg’s picture

I should add that I really don't need any coupons or complex modules and would like to avoid it if possible. It's a simple "class sign up" site with no taxes, no shipping, but the customers do sometimes receive a hardship discount. I have added a Variable Price feature to allow them to type in an adjustment to the price by adding a "Price Adjustment" product to the cart, and I would like to just have the variable amount available that they can type.
Is there any way to do this? Thanks!

Island Usurper’s picture

Status: Reviewed & tested by the community » Fixed

It should work as patched, so, MBroberg, I'd have to see your code to see why it doesn't work for you.

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Dubber Dan’s picture

would be ideal if this was added in to core. any plans?

ricky.ybarra’s picture

Thanks for sharing. Works great!

adTumbler’s picture

Version: 6.x-2.2 » 6.x-2.4

I have just upgraded to 2.4

I noticed that I needed to re-apply this patch - thought it would be worth noting this for any other users upgrading to 2.4 who have implemented this capability.

Alex

joelstein’s picture

Subscribing... #17: that's because it was committed after the 2.4 release. It should be a part of the 6.x-2.5 release, whenever that is.

aaronbauman’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Component: Code » Documentation
Category: feature » bug
Status: Closed (fixed) » Needs review
StatusFileSize
new716 bytes

I'm using Ubercart 2.7, but the following caveat still appears:

You must use a single line item on your site if you have any fees or discounts besides shipping and tax.

As I read this thread, it looks like the patch above (and now in UC core) is supposed to alleviate this constraint, but the caveat was overlooked and should have been removed.

If this is a documentation bug, then please see the attached patch for review.
If this is totally unrelated, please point me in the right direction (and explain to me what that caveat is talking about if not this exact case).

Status: Needs review » Needs work

The last submitted patch, uc_paypal-wpp-itemized-815482-19.patch, failed testing.

longwave’s picture

Status: Needs work » Fixed

Committed #19 to both branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.