Skip to content

Commit

Permalink
fix(cron): don't crash when (canceled) product have 0 qty (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-hours authored Oct 10, 2024
1 parent 154ba64 commit 2047093
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion classes/models/LengowProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,12 @@ public static function extractProductDataFromAPI($api)
foreach (self::$productApiNodes as $node) {
$temp[$node] = $api->{$node};
}
$temp['price_unit'] = (float) $temp['amount'] / (float) $temp['quantity'];
$qty = (float) $temp['quantity'];
if ($qty <= 0) {
$temp['price_unit'] = 0;
} else {
$temp['price_unit'] = (float) $temp['amount'] / $qty;
}

return $temp;
}
Expand Down

0 comments on commit 2047093

Please sign in to comment.