DragonByte eCommerce : Country List not showing

swift

Well-known member
Registered
Joined
Apr 7, 2019
Messages
63
Points
28

Reputation:

I'm unable to set up current add-on, I have filled all details in invoice options and the only thing left is country but there are no options in the list to select other than "NONE"

Is there anyway of bypassing this or fixing this?

Screenshot 2021-10-09 004215.jpg


Screenshot 2021-10-09 004311.png
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
796
Points
153

Reputation:

swift

Well-known member
Registered
Joined
Apr 7, 2019
Messages
63
Points
28

Reputation:

Hondo

SVIP Member
S.V.I.P Member
Registered
Joined
Aug 22, 2021
Messages
11
Points
3

Reputation:

Self Issue here, no countrys....
Addon error?
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
796
Points
153

Reputation:

For physical items you need to add Shipping zones, then the country.

Where did you get this dropdown list, is it if you buy your product, like this:
1633940562900.jpg
 

swift

Well-known member
Registered
Joined
Apr 7, 2019
Messages
63
Points
28

Reputation:

For physical items you need to add Shipping zones, then the country.

Where did you get this dropdown list, is it if you buy your product, like this:
View attachment 25868
BattleKingThat comes to another issue you can't enter the shipping zone:

Screenshot 2021-10-11 174518.jpg

Again you can't buy your own products because your locked out with further errors:

Screenshot 2021-10-11 174004.jpg


It just simply fudged unless there is something i can tweak to bypass this country bug, the settings are set up but it's the country that's stopping us going further
 

WinSys32

nullscriptz.nl
Collaborate
Registered
Joined
Oct 10, 2019
Messages
39
Points
43

Reputation:

In your admin panel, go to dragonbyte ecommerce, go to settings and their you find the settings. Fill in some, no one will see it as long as you don't offer bank transfers :)
 

Hondo

SVIP Member
S.V.I.P Member
Registered
Joined
Aug 22, 2021
Messages
11
Points
3

Reputation:

No chance, Country pulldown is empty.

best regards
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
796
Points
153

Reputation:

Here we got a problem with the restcountries api, this has been changed and it requires now an API key, even the URL has been changed.

This has been solved with the 2.4.0 version

Fix: Updated the Country API to account for changes in 3rd party services (now requires an API key)
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
796
Points
153

Reputation:

I made some changes on the file: src\addons\DBTech\eCommerce\Repository\Country.php

getUntrusted('https://restcountries.eu/rest/v2/all');
is getting to
getUntrusted('http://api.countrylayer.com/v2/all?access_key=YOUR_API_KEY');

Example entry of requested api:
[{"name":"Afghanistan","topLevelDomain":[".af"],"alpha2Code":"AF","alpha3Code":"AFG","callingCodes":["93"],"capital":"Kabul","altSpellings":["AF","Af\u0121\u0101nist\u0101n"],"region":"Asia"}

The native_name do not exist any more, so I changed as well:
'native_name' => $country['native_name'],
to
'native_name' => $country['name'],

PHP:
    public function updateCountryList(): bool
    {
        $reader = $this->app()
            ->http()
            ->reader()
        ;

        $countryList = null;
       
        try
        {
            $response = $reader->getUntrusted('http://api.countrylayer.com/v2/all?access_key=YOUR_API_KEY');
            if ($response)
            {
                $jsonText = $response->getBody()->getContents();
               
                $response->getBody()->close();
               
                if ($response->getStatusCode() == 200)
                {
                    try
                    {
                        $countryList = \GuzzleHttp\json_decode($jsonText, true);
                    }
                    catch (\InvalidArgumentException $e)
                    {
                        \XF::logException($e, false, 'Security error:');
                        return false;
                    }
                }
                else
                {
                    \XF::logError(\XF::phraseDeferred('received_unexpected_response_code_x_message_y', [
                        'code' => $response->getStatusCode(),
                        'message' => $response->getReasonPhrase()
                    ]));
                    return false;
                }
            }
        }
        catch (\GuzzleHttp\Exception\RequestException $e)
        {
            \XF::logException($e, false, 'eCommerce error:');
            return false;
        }

        if (!is_array($countryList))
        {
            return false;
        }
       
        /** @var \DBTech\eCommerce\Entity\Country[]|\XF\Mvc\Entity\ArrayCollection $existingCountries */
        $existingCountries = $this->findCountriesForList()->fetch();

        $currentCountries = [];
        foreach ($countryList as $country)
        {
            if (!isset($existingCountries[$country['alpha2Code']]))
            {
                /** @var \DBTech\eCommerce\Entity\Country $newCountry */
                $newCountry = $this->em->create('DBTech\eCommerce:Country');
                $newCountry->bulkSet([
                        'country_code' => $country['alpha2Code'],
                        'name' => $country['name'],
                        'native_name' => $country['name'],
                        'iso_code' => $country['alpha3Code'],
                    ]);
                $newCountry->save();
               
                $currentCountries[$country['alpha2Code']] = $newCountry;
            }
            else
            {
                /** @var \DBTech\eCommerce\Entity\Country $newCountry */
                $newCountry = $existingCountries[$country['alpha2Code']];
               
                if ($newCountry->name != $country['name'])
                {
                    $newCountry->fastUpdate('name', $country['name']);
                }
               
                $currentCountries[$country['alpha2Code']] = $newCountry;
            }
        }
       
        $missingCountries = array_diff_key($existingCountries->toArray(), $currentCountries);
       
        /** @var \DBTech\eCommerce\Entity\Country $country */
        foreach ($missingCountries as $country)
        {
            $country->delete();
        }
       
        return true;
    }

After that run the two cron entries:

  1. DragonByte eCommerce: Update country list DragonByte eCommerce
  2. DragonByte eCommerce: Update VAT rates DragonByte eCommerce
 

swift

Well-known member
Registered
Joined
Apr 7, 2019
Messages
63
Points
28

Reputation:

I made some changes on the file: src\addons\DBTech\eCommerce\Repository\Country.php

getUntrusted('https://restcountries.eu/rest/v2/all');
is getting to
getUntrusted('http://api.countrylayer.com/v2/all?access_key=YOUR_API_KEY');

Example entry of requested api:
[{"name":"Afghanistan","topLevelDomain":[".af"],"alpha2Code":"AF","alpha3Code":"AFG","callingCodes":["93"],"capital":"Kabul","altSpellings":["AF","Af\u0121\u0101nist\u0101n"],"region":"Asia"}

The native_name do not exist any more, so I changed as well:
'native_name' => $country['native_name'],
to
'native_name' => $country['name'],

PHP:
    public function updateCountryList(): bool
    {
        $reader = $this->app()
            ->http()
            ->reader()
        ;

        $countryList = null;
       
        try
        {
            $response = $reader->getUntrusted('http://api.countrylayer.com/v2/all?access_key=YOUR_API_KEY');
            if ($response)
            {
                $jsonText = $response->getBody()->getContents();
               
                $response->getBody()->close();
               
                if ($response->getStatusCode() == 200)
                {
                    try
                    {
                        $countryList = \GuzzleHttp\json_decode($jsonText, true);
                    }
                    catch (\InvalidArgumentException $e)
                    {
                        \XF::logException($e, false, 'Security error:');
                        return false;
                    }
                }
                else
                {
                    \XF::logError(\XF::phraseDeferred('received_unexpected_response_code_x_message_y', [
                        'code' => $response->getStatusCode(),
                        'message' => $response->getReasonPhrase()
                    ]));
                    return false;
                }
            }
        }
        catch (\GuzzleHttp\Exception\RequestException $e)
        {
            \XF::logException($e, false, 'eCommerce error:');
            return false;
        }

        if (!is_array($countryList))
        {
            return false;
        }
       
        /** @var \DBTech\eCommerce\Entity\Country[]|\XF\Mvc\Entity\ArrayCollection $existingCountries */
        $existingCountries = $this->findCountriesForList()->fetch();

        $currentCountries = [];
        foreach ($countryList as $country)
        {
            if (!isset($existingCountries[$country['alpha2Code']]))
            {
                /** @var \DBTech\eCommerce\Entity\Country $newCountry */
                $newCountry = $this->em->create('DBTech\eCommerce:Country');
                $newCountry->bulkSet([
                        'country_code' => $country['alpha2Code'],
                        'name' => $country['name'],
                        'native_name' => $country['name'],
                        'iso_code' => $country['alpha3Code'],
                    ]);
                $newCountry->save();
               
                $currentCountries[$country['alpha2Code']] = $newCountry;
            }
            else
            {
                /** @var \DBTech\eCommerce\Entity\Country $newCountry */
                $newCountry = $existingCountries[$country['alpha2Code']];
               
                if ($newCountry->name != $country['name'])
                {
                    $newCountry->fastUpdate('name', $country['name']);
                }
               
                $currentCountries[$country['alpha2Code']] = $newCountry;
            }
        }
       
        $missingCountries = array_diff_key($existingCountries->toArray(), $currentCountries);
       
        /** @var \DBTech\eCommerce\Entity\Country $country */
        foreach ($missingCountries as $country)
        {
            $country->delete();
        }
       
        return true;
    }

After that run the two cron entries:

  1. DragonByte eCommerce: Update country list DragonByte eCommerce
  2. DragonByte eCommerce: Update VAT rates DragonByte eCommerce
BattleKingHat off to you dude, That fixed my issue i was about to give up but you saved the day! Thanks again for your help with this.
 

soner

Collaborate
Collaborate
Registered
Joined
Jul 28, 2021
Messages
17
Points
13

Reputation:

I did what you said, it didn't work, it's a country problem, am I missing somewhere, I wonder where these two updates are?

my version 2.3.2
 

BattleKing

Spirit of darkness
Staff member
Administrator
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
May 24, 2020
Messages
796
Points
153

Reputation:

I did what you said, it didn't work, it's a country problem, am I missing somewhere, I wonder where these two updates are?

my version 2.3.2
sonerCheck under cron jobs and execute them manually, but if you got the original code it will fail, because the URL do not exist or is not supported anymore.

I did my tests with 2.3.4 so far as I remember, but my changes should also work with your version.

If you need more help, you can sent me a login to your site via PM
 
Top