Fix undefined discountPercentage by providing default value

Previously, the absence of a discountPercentage caused issues. The code now uses a default value of 0 to ensure stability and prevent potential errors when the discount is not set.
This commit is contained in:
Jepp9350
2025-02-17 13:12:57 +01:00
parent 67e6bb8bf2
commit 9272342c3a
@@ -73,7 +73,7 @@ class economicCustomers extends economic_m
$products = $this->getCustomerProducts($customer_number, 1)->collection;
$discount = $this->getCustomerProductDiscount($customer_number, $products[0]->product->productNumber);
// Since the discount is global, we only need to get the discount for one product
return $discount->discountPercentage;
return $discount->discountPercentage ?? 0;
}
public function getCustomerProducts(int $customer_number, int $limit = 10, int $page = 1): object