Is it possible to show the discount available on the cart and checkout pages rather than just the review page?

Comments

mwisner’s picture

Category: support » bug
Status: Active » Needs review

Hello,
I believe that the problem regarding the checkout preview is a bug in the uc_discount_calculate_discounts function, or in the JavaScript somewhere. Basically, when the JavaScript gets the order information it sets $order->uid = 0 (not sure if this a bug, or intended). This results in the $account argument being set to the anonymous user, so if you have conditions based on $account they will return false.
I have modified

function uc_discount_calculate_discounts($order) {
  global $user;

  if (isset($order->uid)) {
    $account = user_load($order->uid);
  }
  else {
    $account = $user;
  }....

to

function uc_discount_calculate_discounts($order) {
  global $user;

  if ($order->uid > 0) {
    $account = user_load($order->uid);
  }
  else {
    $account = $user;
  }...

This modification seemed to fix the checkout preview for me.

--Matt.

julien verkest’s picture

If you have a javascript error in the path /cart/checkout replace all selectors $("input[@name ...") by $("input[name ...") on the uc_discount.js

giorgosk’s picture

Good one Matt,
here is a patch
applying this to the 6.x dev 2009-Aug-22 will have the discount appear on the checkout page
apply from the drupal root directory

scott m. sanders’s picture

Can someone update this patch or roll it into the module? I wish to review it.

joachim’s picture

Status: Needs review » Postponed (maintainer needs more info)

As far as I can tell, discounts do show on cart and checkout pages.

Can you explain how to reproduce the problem?

scott m. sanders’s picture

Sorry, somehow I thought this issue was for order discounts.

Yes, other discounts do apply in cart and checkout.

joachim’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Okay going to mark this as duplicate then, and assume it was fixed elsewhere.

pyxio’s picture

Discounts do not show for me either on the cart or checkout pages. Only on the final invoice. I have configured my discounts accordingly... 1) Trigger = Calculate Order Discounts 2) Condition = Check the order total 2) Action = Apply A Discount. I see there was a patch for this written back in 2009 which is a long time ago. So I'd like to ensure that it still works before applying it. Thanks. Kevin

joachim’s picture

> So I'd like to ensure that it still works before applying it.

The best person to check that is you. On your dev site, of course, not your live one.

pyxio’s picture

I can see that this patch is already incorporated into the module. So there is nothing to patch. Any other ideas why discounts are not appearing on checkout and review pages? I have tried several themes so it is not a theme issue. Thank you. Kevin

screenage’s picture

I have the latest dev, and my discounts aren't show either on the checkout page.
They are however visible on the review page.

screenage’s picture

StatusFileSize
new386 bytes

Comment #2 though seemed to fix the problem.
I attached a patch for it

screenage’s picture

StatusFileSize
new1.17 KB

better patch (some more replacements)