I have UC Discount Coupons installed and set up a couple of coupon codes. If I add a product to my cart then go to checkout and apply the code, I see the discount and the confirmation message. All is well.
If I enter a coupon code (the same one or a different one) and hit apply AGAIN, it shows the confirmation message and applies the correct discount(s).
If I refresh the page, the discount is still applied, but if I enter a coupon code again and hit apply, I get this error:
Notice: Undefined property: stdClass::$cost in UcOrderProductController->buildContent() (line 89 of /sites/all/modules/ubercart/uc_order/uc_order.controller.inc).
I also get the confirmation message and the discount is still correct.
If I try to apply a coupon code one more time, the error disappears and the discount is still there.
The error/notice only appears:
1. The first time I try entering a coupon code after a /cart/checkout page refresh
2. If there are already coupons applied to the order
It doesn't seem to break anything, and it's highly unlikely that anyone would refresh the checkout page after already applying a coupon, but I stumbled upon it and though I'd check in.
I also posted this here because I wasn't sure which module was the issue: https://drupal.org/node/2041061
Comments
Comment #1
ennazussuzanne CreditAttribution: ennazussuzanne commentedI had the same problem until I changed the coupon to applying to all matching products.
This is possible in store->coupons-> change (I can't come up with the English term right now, I'm using a translation)->apply coupon code to-> all matching products
I hope this helps.
Comment #2
hockey2112 CreditAttribution: hockey2112 commentedI am getting the same exact error message. Is there any fix available? I tried the fix in comment #1, but it changed nothing.
Comment #3
aniruddhay CreditAttribution: aniruddhay commentedSame here, #1 does not work.
Comment #4
felixbachman CreditAttribution: felixbachman commentedHere is the issue:
It happens when a coupon is shown as a item in the cart. The uc_coupon module in this case generates a "fake" item in function (_uc_coupon_cart_item) to be shown in the cart. This generated item does not have a 'cost' value assigned.
If ubercart now generates the content of the cart AND the user has the permission 'administer products' then the uc_order.controller assumes that there is a 'cost' parameter. If it isn't there the error occurs.
There are two possible ways how to solve this issue:
1) Just add 'cost' => 0, in the function _uc_coupon_cart_item of the module uc_coupon.module line 1659
2) or, in uc_order.controller.inc line 89 replace
'#price' => $product->cost, with
'#price' => isset($product->cost) ? $product->cost : '',
Hope this help someone
Felix
Comment #5
ryank76 CreditAttribution: ryank76 commentedFirst fix in #4 worked for me, thanks.
Comment #6
chris.jichen CreditAttribution: chris.jichen commented#4 first fix works for me as well. I used the first fix because i think it is the bug for uc_coupon module.
Comment #6.0
chris.jichen CreditAttribution: chris.jichen commentedAdded link to other post.
Comment #7
DrCord CreditAttribution: DrCord commentedI had to use both fixes in #4 as I was still getting the error on the checkout page review page if I only used the first one. I agree it is probably really a problem with the coupons module and how it creates a fake product, but it isn't terrible for ubercart to check for a value existing before setting it and relying on it being set...
Comment #8
webservant316 CreditAttribution: webservant316 commented#4 worked for me with (1) alone. Hoping this fix gets added to uc_coupon. patches are a pain to maintain.
Comment #9
carlodimartino CreditAttribution: carlodimartino commentedThanks! #4 2) worked for me.
Comment #10
ytsejam CreditAttribution: ytsejam commented#4 worked for me too, thanks!
Comment #11
webservant316 CreditAttribution: webservant316 commentedthis fix was not included in the latest release. Reapplied fix as noted in #4