Coupon gets added to order leads to:

Notice: Undefined property: stdClass::$weight_units funktiossa uc_order_condition_products_weight() (row 446 in file/home/biovasa/biovasa.fi/sites/all/modules/ubercart/uc_order/uc_order.rules.inc).

CommentFileSizeAuthor
#10 1416322-weight-units.patch663 byteswodenx
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wodenx’s picture

Project: Ubercart » Ubercart Discount Coupons
Version: 7.x-3.0-rc4 » 7.x-2.x-dev
Component: Orders » Code
Status: Active » Postponed (maintainer needs more info)

Moving to uc_coupon queue.
- What version of uc_coupon are you using?
- What page do you get the error on?
- What rule is that condition a part of?

Demoshane’s picture

- 7.x-2.1-alpha5+3-dev
- When trying to access checkout after adding coupon
- Havent got any specific rules set up. Just initial ones

Have got weight based shipping costs enabled though. And uc global quote.

wodenx’s picture

Component: Code » Documentation

Does this happen if you disable uc_global_quote?
What are the exact conditions you have set up for weight based quotes?
Just to clarify - you're saying this only happens if you enter the coupon on the 'cart' page and then hit "checkout"?
Do you have multiple coupons enabled?
What are the settings for the coupon that causes the problem?
As always, a link to a site that demonstrates the problem would be helpful.
Thanks.

Demoshane’s picture

Doesnt happen with UC_global_quote disabled

uc-global quote settings
Min weight 0, max weight 1kg, shipping rate 6,48€

Only checkout. If applied at cart page it goes to checkout but after clicking review it sends back to cart page and after that you cant access checkout anymore.

No

Settings: -20% Total of matching

Can't provide link as webstore side is work in progress and can't be published.

wodenx’s picture

Still can't reproduce this, but there are a lot of variables.
You must have some weight-based condition executing - can you visit admin/config/workflow/rules/components and see if there are any condition sets that are checking an order's weight?
What checkout panes are enabled and what order are they in?
I still don't have a clear idea of the exact steps needed to reproduce the problem.
Here's what I've done:
1- created a single uc_global_quote as defined above (had to create a single zone).
2- defined a coupon offering a 20% discount
2- defined a shippable product with a weight of 0.5kg
3- added that product to the cart
4- proceeded to checkout
5- applied the coupon
6- proceeded to review
No error message.

Also have tried adding a condition to the quote (total weight > 0kg) and applying the coupon on the cart page.
No error message.

Can you post a similar list of steps that produces the error on your site?

Demoshane’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

1. Enabled global quote
2. Defined coupon -20% total of matching products
2. Created zone Countries "Finland" zone "All"
3. Created global quote with minimum weight 0,00 Maximum weight 2,00, shipping rate 6,49€
4. Logged in as dummy customer account with blank cart
5. Added product with 1kg weight to cart
6. At cart window gave coupon code and applied it
7. Continued to checkout and filled information
8. Selected global quote as delivery method (tried others too to see if they produce error)
9. Proceeded to review which seems to work this time after recreating global quote.

List on panes: Cart contents, Customer information, delivery information, billing information, special discounts, coupon discounts, calculate shipping costs, payment method, extra information.

Can't replicate it anymore either. Recreating rules removed the error even they're identical to original ones.

Dylanotron’s picture

I am getting this error when I do the following:

1. add a product to the cart (any product will do.)
2. View cart and add coupon code
3. Proceed to checkout.
4. Receive the error message in checkout:
Notice: Undefined property: stdClass::$weight_units in uc_order_condition_products_weight() (line 495 of /home/dyoung/public_html/main/sites/all/modules/ubercart/uc_order/uc_order.rules.inc).

I'm using:
Drupal Pressflow 7.12
uc_coupon 7.x-2.1-alpha6+8-dev
ubercart 7.x-3.0-rc4+68-dev
rules 7.x-2.1 (2012-03-16)

I have not enabled uc_global
I have created and activated multiple coupons

Shipping Methods enabled:
UPS (no conditions) [UPS automatically doesn't return quotes for freight weight: 150+ lbs]
"Standard Shipping" condition - $10.00 = if all products total weight is less than 150 lbs AND delivery address = U.S. AND Order Total < $150 (includes 2 data comparisons and then one "check and order's total weight")
"Free Shipping" condition - $0.00 = if all products total weight is less than 150 lbs AND delivery address = U.S. AND Order Total > $150 (includes 2 data comparisons and then one "check and order's total weight")
"Refrigerator Shipping" condition - $125.00 = if all products total weight is more than 150 lbs. (includes one "check and order's total weight")
"Customer Pick-up" condition - $0.00, (no conditions)

Because I get the error twice after moving to the checkout screen, maybe ubercart isn't finding a $weight_units attribute for the coupon code when applying the "Check an Order's Total Weight" shipping condition. In my case, because the item I added was under $150, the "Check an Order's Total Weight" conditional check would have run twice. However, if I add a product more than $150, the error appears twice on the checkout page as well.

#6 says "recreating rules removed the error." Some of my tax rules cannot be reverted (this may be because i tried to delete some of them manually from the database at one point.) I recreated my shipping quotes and conditions (except for UPS) but still receive the error. The only conditions in /admin/config/workflow/rules/components that check an order's weight are mentioned above.

Checkout Panes, in order:
Cart Contents
Customer information
Delivery Information
Billing Information
Calculate shipping cost
Coupon discount
Payment method
Order options (custom pane)
Order comments

ñull’s picture

Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)

I have the same issue here. I can send you a drush produced archive of the site to your email address to reproduce the error. The problem is that the error is not triggered consistently.

Allthegearnoidea’s picture

I get the same warning message. I have Weight Quote 7.x-3.2 under Ubercart fulfillment enabled. By disabling this the warning goes away.

I have tried recreating my shipping quotes but that does not solve the problem.

Am using Ubercart 7.x-3.2 and Ubercart Discount Coupons version 7.x-2.1-alpha7

Happy to post any further info you need.

wodenx’s picture

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

Please try attached patch.

Allthegearnoidea’s picture

Bearing in mind that I am a complete novice when it comes to applying patches (and that I did it manually)... I think I have successfully applied the patch but I now get the following message:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/rattryde/public_html/sites/all/modules/uc_coupon/uc_coupon.module on line 1678

Of course it could just be that I mucked it up so we might need someone more proficient in the application of patches to post.

wodenx’s picture

hm. that sounds like you didn't apply the patch properly. If you are on a linux/osx system, you can simply:

cd /path/to/uc_coupon
patch -p1 < path/to/patchfile

Instructions for windows can be found at http://drupal.org/node/60179

Allthegearnoidea’s picture

Must admit I thought as much. Will start again afresh...

Allthegearnoidea’s picture

Just tried to apply the patch using cygwin but get:

Hunk #1 FAILED at 1660.

1 out of 1 hunk FAILED

Allthegearnoidea’s picture

Hi

I've got the patch to work!!! And the error message has now disappeared and the discount is applying properly.

All I did was I changed the version of Discount Coupons I'm using to 7.x-3.0-alpha0+3-dev then applied the patch manually. The only thing to note is the patch says to start at line 1660 but actually the piece of code that the changes started at i.e. the first change to implement was at line 1859 in the version of Discount Coupons I am using (7.x-3.0-alpha0+3-dev).

Hope this helps others.

Allthegearnoidea’s picture

Forgot to add I used this http://drupal.org/node/534548 for the guide on applying the patch manually

5kot’s picture

Issue summary: View changes

I had the same issue with the patch, so applied it manually and it's worked.

I was on 7.x-2.1-alpha7, so upgraded to 7.x-3.0-alpha0 then applied the patch,

edit: oh, I see. The patch was for 7.x-2.x-dev.

5kot’s picture

This seems to be a pretty innocuous patch. It's just adding default attributes for the line item. Any chance of this being rolled into trunk?