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

attar_eweev created an issue. See original summary.

DamienMcKenna’s picture

Assigned: m.attar » Unassigned
Status: Needs work » Active
Issue tags: -Eweev

FYI 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".

DamienMcKenna’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev

Have you tested with alpha6?

JulienF’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha6

Hi Damien,

I've tested with alpha6 and the same error still applies.

Any idea ?

m.attar’s picture

@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.

m.attar’s picture

Status: Active » Needs review
joelpittet’s picture

Status: Needs review » Active

There is no patch, leaving this as active. For reference on what status to use. @see https://www.drupal.org/node/156119#needs-review

vasike’s picture

i 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

torgosPizza’s picture

@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!

arunkumark’s picture

Hi 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.

torgosPizza’s picture

@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!