uc_discount_price_handler_alter tests the value of $context['type'] and if it's not 'product' or 'cart-item' then nothing happens.

As far as I can tell, there is no key 'type' in the context array, not on node view, not on cart, not at checkout.

Perhaps this should be 'location'?

CommentFileSizeAuthor
#1 578196-uc_discount-fix-API.patch2.01 KBjoachim

Comments

joachim’s picture

Status: Active » Needs review
StatusFileSize
new2.01 KB

Here's a patch.
It appears to work -- I have a CA for product price which has an effect on the node, the cart, and at checkout.

Please bear in mind that I've fixed this by trial and error -- someone who made what I assume are big changes to the CA API should review this and make sure all possibilities are covered.

joachim’s picture

This doesn't cover the price field in views. I'll open a new issue for that as it's going to get complex: #579162: Discounts don't work in views price field.

joachim’s picture

Status: Needs review » Needs work

This doesn't correctly work at checkout:
- the Cart contents pane is correct
- the Payment method pane is not.

A lot of different values of $context['location'] get passed in, and without documentation (#579188: missing info in documentation for hook_uc_price_handler) I can't tell I've got them all.

joachim’s picture

It seems I'm chasing Ubercart RCs... http://drupal.org/node/475474
This has all changed in very recent releases so it looks like this patch might be irrelevant.

Island Usurper’s picture

Yeah, sorry. I probably should have said something before you did too much work on this. I'm trying to get Ubercart 2.0 out the door, so I haven't really had time to work on this. If you want to keep up with the very latest Ubercart code, you can access our Bazaar repository by following the instructions at http://www.ubercart.org/bazaar.

joachim’s picture

Status: Needs work » Closed (works as designed)

Heh, I went into overdrive mode as my project launches on Friday... ;)
It looks like you've actually been keeping this in sync with the latest stuff to land in UC core :)

I'll close this as by design, as it works with the latest RC6.