Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I have discount with Offer type "Free products", I used it on order and it works good(order have line item product_disount),
But when I completed the checkout the line item product_discount disappear from the order so all free products disappear also,
Which is provide a problem, because when the user would check his order completed he could not see the "Free products" earned.
Can anybody help me out with this?
Thanks.
Comments
Comment #2
DamienMcKennaFYI you should set the status to "active" when you create a new ticket, "needs work" is for when there's a patch that needs further improvements and is not just to say "this problem needs to be worked on".
Comment #3
DamienMcKennaHave you tested with alpha6?
Comment #4
JulienF CreditAttribution: JulienF at Eweev LTD commentedHi Damien,
I've tested with alpha6 and the same error still applies.
Any idea ?
Comment #5
m.attar CreditAttribution: m.attar commented@DamienMcKenna Thank you for your notice.
For the bug, Its problem cache, So after the order refreshed using commerce_discount_commerce_cart_order_refresh()
it stored in the database but the orders cache does not reset, and in the next calling of commerce_order_load() it load caching order rather of refreshed order which provides problems to complete the checkout process.
Obviously the solution is to reset the cache before the calling of commerce_order_load(), So I created custom code to solve this problem:
function [MODULE_NAME]_form_alter(&$form, &$form_state, $form_id) {
if(!empty($form['buttons']['continue']['#validate']) and
in_array("commerce_checkout_form_validate", $form['buttons']['continue']['#validate'])){
array_unshift($form['buttons']['continue']['#validate'], "commerce_discount_reset_order_cache");
}
}
function commerce_discount_reset_order_cache($form, $form_state){
entity_get_controller("commerce_order")->resetCache();
}
Thanks.
Comment #6
m.attar CreditAttribution: m.attar commentedComment #7
joelpittetThere is no patch, leaving this as active. For reference on what status to use. @see https://www.drupal.org/node/156119#needs-review
Comment #8
vasikei can confirm this issue
I tried with some patches for other issues and it seems they could do the job done
i'm talking about
https://www.drupal.org/files/issues/during_ajax_form-1804592-88.patch
and https://www.drupal.org/node/2593983#comment-10556532
Comment #9
torgosPizza@vasike: That's great to hear! It does seem like ensuring $order integrity at the checkout pane level is solving many issues. Thanks for letting us know!
Comment #10
arunkumarkHi All,
Am also facing the similar problem(+1).
In my case, we using one-page checkout with Shipping service(commerce_shipping module) along with Discount (commerce_discount). When shipping service recalculated(on changing values) the discount disappears. But actually it present in Order object.
On analysis, it may the order object($form['object']) not get updated with latest changes.
Comment #11
torgosPizza@arunkumark:
Now that #1804592: During AJAX form submission in checkout, the $order argument passed by the Form API is incorrect. has landed, you might try with the latest version. (Or give the patch in that issue a try.) I think the last few patches to make it into Commerce core will have solved most of these long-standing bugs, but additional testing is appreciated!