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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user