|
9 | 9 | use Igniter\Cart\Models\Order; |
10 | 10 | use Igniter\Flame\Exception\ApplicationException; |
11 | 11 | use Igniter\Flame\Geolite\Facades\Geocoder; |
| 12 | +use Igniter\Flame\Geolite\Model\Location as UserLocation; |
12 | 13 | use Igniter\Local\Classes\CoveredArea; |
13 | 14 | use Igniter\Local\Classes\Location; |
14 | 15 | use Igniter\Local\Models\LocationArea; |
@@ -151,14 +152,17 @@ public function validateDeliveryAddress(array $address): void |
151 | 152 | $address['country'] = app('country')->getCountryNameById($address['country_id']); |
152 | 153 | } |
153 | 154 |
|
154 | | - $collection = Geocoder::geocode(implode(' ', array_only($address, [ |
155 | | - 'address_1', 'address_2', 'city', 'state', 'postcode', 'country', |
156 | | - ]))); |
| 155 | + $addressInfo = array_only($address, ['address_1', 'address_2', 'city', 'state', 'postcode', 'country']); |
| 156 | + if (empty($addressInfo)) { |
| 157 | + throw new ApplicationException(lang('igniter.local::default.alert_invalid_search_query')); |
| 158 | + } |
157 | 159 |
|
| 160 | + $collection = Geocoder::geocode(implode(' ', $addressInfo)); |
158 | 161 | if ($collection->isEmpty()) { |
159 | 162 | throw new ApplicationException(lang('igniter.local::default.alert_invalid_search_query')); |
160 | 163 | } |
161 | 164 |
|
| 165 | + /** @var UserLocation $userLocation */ |
162 | 166 | $userLocation = $collection->first(); |
163 | 167 | if (!$userLocation->getStreetNumber() || !$userLocation->getStreetName()) { |
164 | 168 | throw new ApplicationException(lang('igniter.local::default.alert_missing_street_address')); |
@@ -428,9 +432,10 @@ public function applyCurrentPaymentFee($code): ?CartCondition |
428 | 432 | $this->setCurrentPaymentCode($code); |
429 | 433 |
|
430 | 434 | $condition = $this->cart->getCondition('paymentFee'); |
431 | | - $condition->setMetaData(['code' => $code]); |
432 | | - |
433 | | - $this->cart->loadCondition($condition); |
| 435 | + if ($condition instanceof CartCondition) { |
| 436 | + $condition->setMetaData(['code' => $code]); |
| 437 | + $this->cart->loadCondition($condition); |
| 438 | + } |
434 | 439 |
|
435 | 440 | return $condition; |
436 | 441 | } |
|
0 commit comments