When we have a percentage off offer subtotal promotion offer and the order doesn't have any items it throws an error.

Comments

istavros created an issue. See original summary.

istavros’s picture

StatusFileSize
new898 bytes
bojanz’s picture

Issue tags: -OrderPercentageOff, -Promotion

The expectation is that promotion don't run on orders without order items. We need to find out why that's not the case here.

Otherwise we'll need to fix more than just this plugin.

istavros’s picture

Then we should probably check this in the PromotionOrderProcessor::process() method.

istavros’s picture

StatusFileSize
new737 bytes
a.dmitriiev’s picture

@istavros, maybe you have a custom order processor, that runs before promotion order processor, that removes order items? Because it was in my case, maybe just move your processor to work after promotions.

But also the patch is solving the issue and I think shop should not process the orders without order items.

Reviewed and tested.

a.dmitriiev’s picture

Status: Active » Reviewed & tested by the community
a.dmitriiev’s picture

StatusFileSize
new734 bytes

re-rolled the patch from #5, so it applies to version 2.17

jsacksick’s picture

Status: Reviewed & tested by the community » Needs work

I think we should add this check in OrderRefresh directly, inside the processors loop:

    foreach ($this->processors as $processor) {
      $processor->process($order);
    }
jsacksick’s picture

Status: Needs work » Needs review
StatusFileSize
new541 bytes

The attached patch should address the issue differently (I check if the order has items after invoking each processor and break the loop if the order doesn't have items anymore.

jsacksick’s picture

StatusFileSize
new542 bytes

Actually, a return statement makes more sense since the loop on order items performed after the loop on processors doesn't even need to be evaluated.

  • jsacksick committed fa32333 on 8.x-2.x
    Issue #3005935 by istavros, jsacksick, a.dmitriiev: Skip invoking order...
jsacksick’s picture

Status: Needs review » Fixed

Committed the patch from #11.

jsacksick’s picture

Title: OrderPercentageOff throws error if there are no order items in the order » Skip invoking order processors when the order has no items

Status: Fixed » Closed (fixed)

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