At some point when upgrading Ubercart, uc_coupon, or Drupal the coupon module began to malfunction and now the checkout coupon value and order sub-total (subtotal) displayed wrong. This is very disconcerting to the customer causing phone calls for help. In the end it seems to be a 'display only' issue because the order can be submitted properly and the subsequent order email and history are correct.

Also note that in my store configuration if the order total is $0, then no payment options are listed because no payment is needed. However, when uc_coupon messes up the sub-total, we see payment options even if the order total is $0 because of the coupons.

See attached jpeg for detailed screen shots. I see there are a number of related posts on this issue, however, none where exactly like my issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webservant316’s picture

Again there were other posts related to this one, so it may all be the same issue.

hoZt’s picture

I was having the same problem and it was solved by adding the coupon pane to the checkout settings. Here is another issue that discusses this:

#1310590: Order total not discounted when "Coupon discount" pane is disabled.

webservant316’s picture

Thanks for the suggestion, but that is not my problem. I have the coupon text box available in both the cart and in the checkout window already.

webservant316’s picture

any help from anyone?

webservant316’s picture

Any tips as to how I can debug this myself? What php file do I need to consider?

webservant316’s picture

ok - I tried to dive into this problem further and this is clearly a bug most likely related to a confused flow of logic. I don't have the time to figure out the patches needed, but maybe the notes below will help the maintainer to work the solution.

1. If I add the coupon from the CART a line for the coupon is added to the CART with the right discount and the subtotal is correct. HOWEVER, when I enter the CHECKOUT in the 'item list section' the line for the coupon then indicates $0 and the item list sub-total doesn't reflect the discount. Furthermore, the 'order total preview' under the payment section show a sub-total that is 2X the proper amount, the coupon is correct, and the total is correct. Weird.

2. If I add the coupon from the CHECKOUT a line for the coupon is NOT added to the item list above (though if I go back to the CART it is there), but in the 'order total preview' section the subtotal, coupon, and total are initially correct. However, if I would go back to the CART and return to CHECKOUT it the same errors would be there as #1 above, if I had initially added the coupon from the CART.

3. Also note that if I add the coupon in the CART, go to CHECKOUT and remove the coupon in CHECKOUT that the coupon is NOT properly removed from the 'item list section', though the 'order total preview' is correct.

For now I plan to hide the coupon add form in the CART section. This will allow the customer to have the least troublesome experience if they simply add the coupon in CHECKOUT and then immediately checkout. However, if they return to their CART and then return to CHECKOUT they will have the problems described in #1 above.

I am surprised that no one else is having this problem.

Jeff

Jukebox’s picture

Status: Active » Needs review
FileSize
678 bytes

Jeff

I too am surprised that no one else is having this problem. I was experiencing the same thing you described (your attached image was helpful). Looking into this issue further, I made a few observations.

As you have noted, the coupon will correctly apply its amount to the grand total when the user completes checkout. Inspecting the contents of the cart shows that the coupon does indeed have the correct amount. So, the coupon is somehow not reflecting its true amount during the preview stages.

One of the culprits of this error lies in the theme_cart_review_table() function in uc_cart_checkout_pane.inc. This function is responsible for showing the cart contents pane on the checkout page (not to be confused with the payment method pane). First, it grabs the entire contents of the cart, and iterates over each $item in the collection. Prior to completing the loop, the coupon has the correct value. When the loop completes, it shows the coupon having a $0 value. Delving into this section of code further, the offending code is on line 630:

$total = uc_price($price_info, $context);

The uc_price function is "The heart of the price modification/displaying system, this function handles price alteration, formatting, theming, and caching." Somehow uc_price doesn't like the coupon $item and sets the value to zero.

I'm not sure why uc_price behaves this way, but on the surface level, it turns out that the coupon $item does not have a node id attached to it. This (directly or indirectly) causes the coupon's value to be set to zero. I may be way off here, but I couldn't deduce anymore than that at this time. Apparently, if you set $item->nid to any PRODUCT node id, then uc_price likes it and retains the coupon's value.

Since uc_price is a fundamental ubercart function and we're talking about uc_coupon, i've created a patch for uc_coupon that grabs one product node id and inserts it into the uc_coupon_uc_cart_alter() function, which causes uc_price to keep the dollar value of the coupon.

Perhaps somebody with a little more understanding of uc_price can shed some more light on this.

webservant316’s picture

yes hopefully

Jukebox’s picture

Jeff, did the patch work for you?

http://drupal.org/patch/apply

webservant316’s picture

dummy me, I didn't see that you had a patch. I will try it shortly.

webservant316’s picture

I hope to get back to this mid-april

webservant316’s picture

The patch appears to work for me. Thanks!

I did notice that if I add a coupon in the checkout pane that the coupon is properly displayed in the sub-total area at the bottom of the page, however, the detailed item list above is NOT updated. However, that may be an unrelated problem.

The vital thing is that the order summary totals are right so that customers will not be confused.