Closed (fixed)
Project:
Commerce Discount
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Sep 2012 at 18:58 UTC
Updated:
21 May 2015 at 05:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
lsolesen commentedDid a print_r() to see what was going on:
Seems that the last "danish_vat" creates the error. I am not sure how that got into the components.
Comment #2
BarisW commentedSame here with latest commerce_discount update. We have a Dutch VAT.
When I change the % discount to a fixed discount, the errors are gone.
The error is that the site crashes on admin/commerce/orders and when ordering products.
Comment #3
pcambraOk, error identified, it's happening for Product % coupons that have taxes included
Comment #4
ericmulder1980 commentedPerhaps some extra info to get this fixed. I am getting this error when i have multiple discounts setup. These are the steps to reproduce this.
1) Setup CK as usual and create some products.
2) Create your first discount based on a percentage, for example 25%
3) Place an order
4) Check your orders overview, everything should still be fine.
5) Create your second discount based on a percentage, for example 50%
6) Place a second order.
It fails as soon as you place a product in your shopping cart and go to your shopping cart page.
Also the order overview now fails with the following error
Now in the above example it will add both the 25% and 50% discount to the same product. In my example i have created a custom rule condition that let's you select a product type and an amount. The rules only fire when you have added a given amount of products of type x. In the rules log i can see that the proper rule is fired.
Hope this gives you some extra information to get this fixed.
Comment #5
ericmulder1980 commentedWhen i disable the rule that does the taxes calculation i still have this error so perhaps it's not related to taxes?
Comment #6
pcambraYeah, I guess it doesn't work very well with multiple price components, that's the reason
Comment #7
dubs commentedI've got this to work by altering the line in question: -
I'm not sure if this just bypasses the double-check, but it stops the error and the cart seems to calculate correctly.
Comment #8
lsolesen commentedExpressed as a patch.
Comment #10
lsolesen commented#8: check-if-array-issue-1789412.patch queued for re-testing.
Comment #12
pcambraFixed it in a slightly different way, see the commit here:
http://drupalcode.org/project/commerce_discount.git/commit/319204a
Thanks for the report and the follow up!!
Comment #13
ericmulder1980 commentedI was extremely happy to see this was fixed. However after some more testing the EntityMetadataWrapperException and DatabaseTransactionOutOfOrderException returned as soon as i have placed multiple orders while having multiple discounts setup.
I will create a new issue with the exact details on how to reproduce this.
Comment #14
BarisW commentedI've spoken with ericmulder1980 and it seems that the steps listed in #4 still produces these errors.
Re-opening this issue as the commit in #12 doesn't fully fix the problem.
Comment #15
pcambraI've just tried the steps in #4 several times:
1) Setup CK as usual and create some products.
2) Create your first discount based on a percentage, for example 25%
3) Place an order
4) Check your orders overview, everything should still be fine.
5) Create your second discount based on a percentage, for example 50%
6) Place a second order.
But I guess I need more info, I've requested the rules that are failing to @ericmulder1980 on Friday, could someone that can reproduce the issue exportthe rules that are affecting this and attach them here?
Comment #16
ericmulder1980 commentedSorry for the delay. Here is the code for the condition. I removed the customer name from the code and changed everything to 'mymodule'.
Implementation of hook_rules_condition_info().
Implementation of hook_rules_condition_info()
The evaluation function for the product type and amount
Hope you can reproduce this with the above code.
Comment #17
ericmulder1980 commentedOk, we finally resolved where this issue comes from. when using the EntityMetadataWrapper to set values for the total_amount in commerce_discount_remove_discount_components() it fails when the given amount is a float value and not an integer value.
The validate function in entity.wrapper.inc validates the $value against $this->type. This results in float == integer, which fails.
So forcing the entered data to be a string fixes this issue and makes me very very very happy :)
Special thanx to pcambra for putting effort into fixing this problem and sharing thoughts on IRC.
Attached patch fixes the issue.
Comment #18
ericmulder1980 commentedchanged status to needs review.
Comment #19
pcambraI've confirmed that this error is only happening with Commerce Kickstart RC1 and it's due that this patch #1518084: Expose a new property to Entity API (Amount floatted) is applied there and not in Drupal Commerce core.
There are plans for removing this from kickstart itself but the workaround in #17 is valid for those affected.
Setting back to fixed as it will be eventually corrected in kickstart.
Comment #21
giorgoskjust noting here that I was getting the same error with CK RC3 but latest DEV of commerce_discount fixed this
Fatal error: Cannot use string offset as an array in /home/domain/public_html/profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.rules.inc on line 143
Comment #23
joelpittet