- Status changed to Needs work
almost 2 years ago 2:53pm 18 January 2023 - πΊπΈUnited States sah62 US
Would something like this work to mark an order item each time is payment is processed?
foreach ($payment->getOrder()->getItems() as $item) { $square_item_processed = $item->getData('square_item_processed', FALSE); if ($square_item_processed) continue; // Process the order item. ... $item->setData('square_item_processed', TRUE); }
I've tried to test this idea. Nothing "bad" seems to happen when I process a first payment for a single item. If I edit the order and add an item, though, when I try to process the second payment the value of $square_item_processed is FALSE for both items in the order and the payment process fails because the amount of the order (2 items, plus tax, plus shipping) doesn't match the payment (1 new item plus tax). I'm clearly still missing something.