Skip to content

Commit

Permalink
hotfix: default country code to Belgium in case geoIp() cannot find t…
Browse files Browse the repository at this point in the history
…he country for a IP address
  • Loading branch information
Nielsvanpach committed Feb 29, 2024
1 parent 7dcac08 commit ac01963
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Domain/Shop/Exceptions/CouldNotFindCountry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Domain\Shop\Exceptions;

class CouldNotFindCountry extends \RuntimeException
{
public static function fromIp(): self
{
return new self();
}
}
6 changes: 6 additions & 0 deletions app/Domain/Shop/Traits/HasPrices.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Domain\Shop\Traits;

use App\Domain\Shop\Exceptions\CouldNotFindCountry;
use App\Domain\Shop\Models\Referrer;
use App\Support\DisplayablePrice;
use Carbon\Carbon;
Expand All @@ -20,6 +21,11 @@ public function getPriceForIp(string $ip): DisplayablePrice
{
$countryCode = geoip($ip)->iso_code;

if ($countryCode === null) {
$countryCode = 'BE'; // @todo temp fix
//CouldNotFindCountry::fromIp();
}

return $this->getPriceForCountryCode($countryCode);
}

Expand Down

0 comments on commit ac01963

Please sign in to comment.