| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | // Check if a valid ID is provided |
| 314 | 314 | if (!$id) { |
| 315 | 315 | return static::makeErrorResponse([ |
| 316 | 316 | ['code' => 403, 'message' => __('Please use a valid address ID!', 'fluent-cart')] |
| 317 | - ]); | |
| 317 | + ], 403); | |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Retrieve the customer address using the ID |
| 321 | 321 | $customerAddress = static::getQuery()->find($id); |
| @@ -324,9 +324,9 @@ | ||
| 324 | 324 | // Check if the address is marked as primary |
| 325 | 325 | if ($customerAddress->is_primary) { |
| 326 | 326 | return static::makeErrorResponse([ |
| 327 | 327 | ['code' => 403, 'message' => __('Primary address cannot be deleted!', 'fluent-cart')] |
| 328 | - ]); | |
| 328 | + ], 403); | |
| 329 | 329 | } |
| 330 | 330 | // Get the count of addresses for this customer |
| 331 | 331 | $addressCount = static::getQuery()->where('customer_id', $customerAddress->customer_id)->count(); |
| 332 | 332 | |
| @@ -333,9 +333,9 @@ | ||
| 333 | 333 | // Check if there's only one address, do not allow deletion in that case |
| 334 | 334 | if ($addressCount <= 1) { |
| 335 | 335 | return static::makeErrorResponse([ |
| 336 | 336 | ['code' => 403, 'message' => __('At least one address must remain. Address deletion failed!', 'fluent-cart')] |
| 337 | - ]); | |
| 337 | + ], 403); | |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // If the address is not primary and there are multiple addresses, proceed with deletion |
| 341 | 341 | if ($customerAddress->delete()) { |
| @@ -344,14 +344,14 @@ | ||
| 344 | 344 | |
| 345 | 345 | // Return an error if the address is not found in the database |
| 346 | 346 | return static::makeErrorResponse([ |
| 347 | 347 | ['code' => 400, 'message' => __('Address deletion failed!', 'fluent-cart')] |
| 348 | - ]); | |
| 348 | + ], 400); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | return static::makeErrorResponse([ |
| 352 | 352 | ['code' => 404, 'message' => __('Address not found in database, failed to remove.', 'fluent-cart')] |
| 353 | - ]); | |
| 353 | + ], 404); | |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * Make primary address for the specified customer. |