Skip to content

Commit

Permalink
Merge pull request #14 from S-Tian86/bugfix/notification-listener
Browse files Browse the repository at this point in the history
bugfix: Validate if quantity has changed
  • Loading branch information
mi-lopez authored Oct 2, 2024
2 parents 1b5c5d4 + ff22d4c commit a9595ec
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ public function postUpdate(): void

protected function inventoryHasNewStock(PreUpdateEventArgs $args): bool
{
$oldQuantity = floatval($args->getOldValue('quantity'));
$newQuantity = floatval($args->getNewValue('quantity'));
if (!$args->hasChangedField('quantity')) {
return false;
}

$oldQuantity = (float) $args->getOldValue('quantity');
$newQuantity = (float) $args->getNewValue('quantity');

return $oldQuantity <= 0 && $newQuantity > 0;
}
Expand Down

0 comments on commit a9595ec

Please sign in to comment.