If I apply a coupon during checkout, then go back and remove all items from the cart, kaboom!
Fatal error: Exception thrown without a stack frame in Unknown on line 0
The logs say:
error type: commerce_line_item
DatabaseTransactionOutOfOrderException: in DatabaseConnection->rollback() (line 1039 of /.../database.inc).
Also (quite possibly related), if I go back and add items and then checkout, sometimes the calculated coupon amount doesn't update at the top of the checkout page (shopping cart contents) while it does update the amount correctly at the bottom where the "coupon code" and "coupon granted amount" are.
Comments
Comment #1
hibersh commentedWhen I apply a coupon during checkout
Error DatabaseTransactionOutOfOrderException: in DatabaseConnection->rollback()
Comment #2
frixos12 commented+1
Comment #3
frixos12 commentedDo we have any information about this exception???
Comment #4
adamgerthel commentedHaving the same issue on an order with only the discount coupon applied on the order (a product was removed) that I tried to change order status on.
Comment #5
hibersh commentedfunction commerce_coupon_basic_apply_percentage_amounts()
Comment #6
hibersh commentedComment #7
frixos12 commenteddoes this patch solves both fixed and percentage coupons?
Comment #8
balintd commented+1 Same error during checkout if coupon applied.
Comment #9
schultetwin commentedThis fixed #1320656: EntityMetadataWrapper Exceptions with commerce coupon. for me.
Comment #10
geek-merlinpatch in #6 removes this nasty bug here too.
attached patch
* is rerolled to module dir and
* changes some more instances of "$coupon->type->type->value()" to "$coupon->value()->type"
which should provide a fix-for-now
but: looks to me like "$coupon->type->type->value()" should work and this is in fact a problem of #1314364: provide entity references as properties
where the offending line comes from:
drupalcode.org Git - project/commerce_coupon.git/blame - modules/basic/commerce_coupon_basic.module
3ea336c6
so i think a proper fix should of that might make this patch obsolete.
Comment #11
fagoThat's probably caused by the application of a not more existing coupon type.
Comment #12
geek-merlin@fago: seems not to be - to not clutter this issue up moved this to #1370046: EntityMetadataWrapperException: Unknown data property type.
Comment #13
geek-merlini think #12 is merely an academic thing so i would appreciate a review or commit (think i thoroughly tested and now it's in production here)
Comment #14
schultetwin commentedI have used this patch and have found no issues with it.
Comment #15
schultetwin commentedOr wait, I'm not sure how you want this, in a new issue or in this one, but I think there is one more instance where $coupon->type->value() needs to be switched to $coupon->value()->type.
Comment #16
geek-merlin@schultetwin: you are completely right.
attached is a patch from #10 extended by #15
Comment #17
geek-merlinhere it comes.
Comment #18
schultetwin commentedTo fast for me, sorry.
Comment #19
geek-merlinno problems, reviewing and rerolling is just one go.
Comment #20
lukusI experienced the same error.
Using Drupal 7.10 - the patch in #17 works for me.
Could this be committed?
Comment #21
geek-merlinand committed.
Comment #23
jonathan_hunt commentedThis still occurs for me on 7.x-1.0-beta4. Add product to cart, apply % coupon, go back to cart, remove product from cart, crash.
Watchdog shows:
and
Comment #24
adamgerthel commentedI just upgraded to latest dev (the beta 4 is full of errors, due to patch from issue #1408800: Abstract and standardize commerce coupon to fix general coupon problems not being applied yet) and I have the same problem, with the following errors when emptying cart with coupons applied:
Warning: array_sum() expects parameter 1 to be array, null given i commerce_coupon_basic_apply_percentage_amounts() (rad 263 av /path-to-site/sites/all/modules/contrib/commerce_coupon/modules/basic/commerce_coupon_basic.module).and:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'commerce_unit_price_amount' cannot be null: INSERT INTO {field_data_commerce_unit_price} (entity_type, entity_id, revision_id, bundle, delta, language, commerce_unit_price_amount, commerce_unit_price_currency_code, commerce_unit_price_data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => commerce_line_item [:db_insert_placeholder_1] => 9054 [:db_insert_placeholder_2] => 9054 [:db_insert_placeholder_3] => coupon [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => SEK [:db_insert_placeholder_8] => a:1:{s:10:"components";a:1:{i:0;a:3:{s:4:"name";s:28:"commerce_coupon_basic_coupon";s:5:"price";a:3:{s:6:"amount";N;s:13:"currency_code";s:3:"SEK";s:4:"data";a:1:{s:10:"components";a:0:{}}}s:8:"included";b:1;}}} ) i field_sql_storage_field_storage_write() (rad 448 av /path-to-site/modules/field/modules/field_sql_storage/field_sql_storage.module).as well as:
DatabaseTransactionOutOfOrderException: i DatabaseConnection->rollback() (rad 1039 av /path-to-site/includes/database/database.inc).Comment #25
pcambraBack to active then. Let's figure out how to reproduce and smash this buggies ;)
Comment #26
bibo commentedSeems the same error is generated under other circumstances too. For example a custom page callback that clears an users cart + adds one item to it sometimes throws this error under load.
Comment #27
pcambraI'm afraid I'm going to need a way to reproduce this, be aware that the module has been changed a lot.
Comment #28
meghanmary commentedI do not get an error but I am not able to remove the coupon from my cart. I am running 7.x-1.0-beta4+14-dev.
I add items to the cart and then add a coupon. I added a percentage based coupon.
I remove the items from the cart. My cart claims that 1 item remains but when I look at the cart it is empty.
If I then add another item to the cart, the previous coupon appears with the amount from the previous order. Is there any way to remove this coupon?
Thanks,
Meghan
Comment #29
adamgerthel commented@meghanmary I'm afraid there's no such functionality. There is a patch in #1305242: Add a Remove coupon view button and Make a User used coupon rule condition but it's not working properly without admin rights.
Comment #30
sleepingmonkHi! I'm testing commerce_coupon-7.x-1.0-beta4+26-dev
Emptying the cart with a coupon in it gives me "The website encountered an unexpected error. Please try again later."
The logs show it's trying to use a column that doesn't exist. I'm assuming this query is checking for coupons to remove from the order when the cart is emptied.
Refreshing or going back shows the cart empty, but as others have mentioned, the coupon is still attached to the order. Adding more products to the order, reveals the coupon again.
Below is from the logs:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_commerce_coupon_reference0.commerce_coupon_reference_coupon_id' in 'where clause': SELECT field_data_commerce_coupon_reference0.entity_type AS entity_type, field_data_commerce_coupon_reference0.entity_id AS entity_id, field_data_commerce_coupon_reference0.revision_id AS revision_id, field_data_commerce_coupon_reference0.bundle AS bundle FROM {field_data_commerce_coupon_reference} field_data_commerce_coupon_reference0 INNER JOIN {commerce_line_item} commerce_line_item ON commerce_line_item.line_item_id = field_data_commerce_coupon_reference0.entity_id WHERE (field_data_commerce_coupon_reference0.commerce_coupon_reference_coupon_id = :db_condition_placeholder_0) AND (field_data_commerce_coupon_reference0.deleted = :db_condition_placeholder_1) AND (commerce_line_item.order_id = :db_condition_placeholder_2) AND (commerce_line_item.type = :db_condition_placeholder_3) AND (field_data_commerce_coupon_reference0.entity_type = :db_condition_placeholder_4) ; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => 64 [:db_condition_placeholder_3] => commerce_coupon [:db_condition_placeholder_4] => commerce_line_item ) in field_sql_storage_field_storage_query() (line 577 of .../public_html/sp/modules/field/modules/field_sql_storage/field_sql_storage.module).Comment #31
sleepingmonkEDITED: Disregard the attached patch. My initial tests weren't thorough enough. I realize now this is incorrect. Will investigate further.
Comment #32
sleepingmonkOk, I did some more digging and I'll admit, I'm pretty confused.
The commerce_coupon.module function on line 667:
As far as I can see, field_data_commerce_coupon_reference doesn't contain anything after I add a coupon to an order, so there's nothing to delete from there. The only table that seems to matter is commerce_coupon_log. Deleting a row from there removes that coupon from an order.
Maybe these are leftovers from changes in the module, but can it be as simple as just deleting all rows from commerce_coupon_log for the order_id? The last part of the function attempts to do this, but doesn't work.
I'm sorry I don't fully grasp what's going on in this complex module. I'm just trying to do what I can to help. This is a very important feature for Drupal Commerce so I'd like to contribute to the best of my ability.
Comment #33
pcambraPushed a big change fixing #1547440: Kill coupon log entity and that should fix all emptying cart problems.
Comment #35
greenavus commentedIt seems i am having this same problem. When there is only one product in the shopping cart, it throws up this error
EntityFieldQueryException: Unknown field: commerce_coupon_reference in EntityFieldQuery->addFieldCondition() (line 770 of C:\wamp\www\Wellness\includes\entity.inc).
Does anyone know what i can do to solve this problem?
Comment #36
greenavus commentedComment #37
pcambraPlease don't revive issues closed 5 months ago. Check the project page for the dedicated issue and the documentation for solving problems like yours, probably related with upgrading from beta4