I haven't looked at why in depth, but when using === the adjustment isn't removed compared to just ==. Something must not be matching up properly and could do with the whole price object string/int/float mess.

CommentFileSizeAuthor
#2 2799375-2.patch763 bytesmglaman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman created an issue. See original summary.

mglaman’s picture

FileSize
763 bytes

here is the patch which gets our tests to pass when remvoving an adjustment.

mglaman’s picture

Status: Active » Needs review
mglaman’s picture

mglaman’s picture

Here's the deal. It might be my implementation. The `===` only works _if it is the exact same object_.

For example, the tests fail with `===` and creating a match object to try and remove.

    // Create new adjustment object, matching existing. Ensure it gets removed.
    $adjustment = new Adjustment([
      'type' => 'custom',
      'label' => '10% off',
      'amount' => new Price('-1.00', 'USD'),
    ]);
    $order->removeAdjustment($adjustment);
<code>

Whereas it passed in test when we have <code>$adjustments[0]

.

So I guess if we want to decide: you must retrieve the object, compare it, and choose to remove it. Or be able to reconstruct the adjustment and say "remove something like this".

mglaman’s picture

Status: Needs review » Closed (won't fix)

You should get the adjustment, verify it, then remove it with the same object.