The api function to remove a coupon from an order doesn't work if there has been made unsaved changes to the coupon entity.

Comments

googletorp’s picture

Status: Active » Needs review
StatusFileSize
new2.16 KB

I've added a simple fix to this bug, by comparing the coupon id instead of comparing the actual coupon entity object.

pcambra’s picture

Status: Needs review » Needs work

Wrong patch? :)

googletorp’s picture

Status: Needs work » Needs review
StatusFileSize
new746 bytes

28 != 82

This is the proper patch.

foopang’s picture

Status: Needs review » Needs work

Hi googletorp, thanks for your patch. But it doesn't work for me.

googletorp’s picture

Status: Needs work » Needs review

#4 Did you use the proper patch, what doesn't work for you? What did you do, what did you expect and what happened?

Simply saying that the patch doesn't work isn't really any help, unless you give some additional information.

I can add that the current patch is successfully being used in production environment.

vadim.eremeev’s picture

StatusFileSize
new1.04 KB

I had the same issue and seems attached patch fix it. Please review.

foopang’s picture

@googletorp I used your patch at comment #3, the coupon attached to the order would still be there after the commerce_coupon_remove_coupon_from_order function call.

Then I tried vadim.eremeev's patch, it worked!

I later found that the condition check of $original_order <> $order at line 622 failed, because $original_order and $order are actually referring to the same object. I think we should better clone the $order object at line 613 instead of removing the condition check at line 622. Patch attached.

googletorp’s picture

#7 It's a good catch, but it's actually a different bug you are fixing. Like I explained in the description of the issue, the bug I found was when the coupon had unsaved changes. I don't know if the best option is to keep this in the same issue, since is concerns the same function or to split it out into different issues.

pcambra’s picture

Status: Needs review » Fixed

Both look great, let's fix both in a row, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.