Prestashop: When multistore is enabled, all countries are displayed in address instead of only those covered by active carriers

Created on 27 Feb 2019  Â·  8Comments  Â·  Source: PrestaShop/PrestaShop

Describe the bug
You are in multistore and have zones, countries enabled for all shops
Carriers are limited to a specific zone
You set _Restrict country selections in front office to those covered by active carriers_ to yes
In front office of both shop while creating a customer address, you will see all countries instead of only ones covered by carriers of the shop.

To Reproduce

  1. Enable multistore in shop parameters > General
  2. Create a second store in advanced parameters > Multistore with default parameters
  3. Go in International > Locations > Zones
  4. Enable Europe & North America for both shops
  5. Go in International >Locations > Countries
  6. Enable France & United states for both shops
  7. Set _Restrict country selections in front office to those covered by active carriers_ to _Yes_ for both shops
  8. Create a carrier 1 for shop 1 that only delivers Europe zone
  9. Create a carrier 2 for shop 2 that only delivers North America zone
  10. Go to shop1 FO and create a customer address, you will see in country list France & US instead of only France
  11. Go to shop2 FO and create a customer address, you will see in country list France & US instead of only US

Suggested fix
The listed countiers should only be what is applicable to the current shop? Proposed change:

line 143 of:

/classes/Carrier.php

to:

$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT cl.*,c.*, cl.nameAS country, zz.nameAS zone, cs.id_shop FROM'._DB_PREFIX_.'countryc'. Shop::addSqlAssociation('country', 'c').' LEFT JOIN'._DB_PREFIX_.'country_langcl ON (c.id_country= cl.id_countryAND cl.id_lang= '.(int) $id_lang.') INNER JOIN ('._DB_PREFIX_.'carrier_zonecz INNER JOIN'._DB_PREFIX_.'carriercr ON ( cr.id_carrier = cz.id_carrier AND cr.deleted = 0 '. ($active_carriers ? 'AND cr.active = 1) ' : ') ').' LEFT JOIN'._DB_PREFIX_.'zonezz ON cz.id_zone = zz.id_zone) ON zz.id_zone= c.id_zone LEFT JOIN'._DB_PREFIX_.'carrier_shopcs ON cr.id_carrier = cs.id_carrier WHERE 1 AND cs.id_shop= ' . $id_shop . ' '.($active_countries ? 'AND c.active = 1' : '').' '.(!is_null($contain_states) ? 'AND c.contains_states= '.(int) $contain_states : '').' ORDER BY cl.name ASC');

1.7.5.2 1.7.6.0 Bug Carriers FO Minor Multistore To Do

All 8 comments

Hi @tonypartridge,

Could you please confirm these steps:

  1. In the countries page, you have two countries:
    1.1 United Kingdom which belongs to the zone "Europe" => selected for the shop1
    1.2 United States which belongs to the zone "North America" => selected for the shop2
    image
  2. In the carrier page, Carrier1 is available for the shop1 (tab2 => multistore) => so in the tab3( Shipping locations and costs), the Zone "North America" should not be selectable?
  3. Same behavior with the Carrier2, Carrier2 is available for the shop2 (tab2 => multistore) => so in the tab3( Shipping locations and costs), the Zone "Europe" should not be selectable?

Thanks!

Hello,

Not quite. All countries are enabled by default and we set: Country Options as:

shipping_options

So at this point we have now said only countries which are assigned to the shops shipping carriers should be shown.

However, if you have two carriers i.e.

  1. DHL UK - Select UK - Store 1
  2. DHL International - Select USA - Store 2

When you edit your address you can select from all countries, this is because the function getDeliveredCountries() is not restricting them to a single shop. The above code change does that.

Many thanks
Tony

@tonypartridge,

I attached a video record.
https://drive.google.com/file/d/1neR2HTcR_AdPVs6i2q0QK_JLJ9iD_0gM/view
Thanks to check & feedback.

Thank you for taking the time to look into this, the issue is you have edited each country and assigned counties to a shop!

We haven’t done that and neither want to, since some shops can ship anywhere in the world it needs to be defined by the carriers zone and not the countries allocated shop then zone. This is why my change above fixes the issue by selecting the shop allocation for the carriers, since you do not want to get shop 1’s carrier countries in shop 2.

@tonypartridge, in your case, all countries are displayed because they are enabled in all shops, which is normal behavior.
But, in my case, I edited the access of countries for each shop => so, in the FO not all the shops are displayed.
@marionf, what do you think?
Thanks!

It’s not normal behaviour as we set ‘restrict countries to carrier countries’ 😜yet we are including carriers from ALL shops. We should only include carriers from this shop.

Get Outlook for iOShttps://aka.ms/o0ukef


From: khouloudbelguith notifications@github.com
Sent: Wednesday, February 27, 2019 2:31 pm
To: PrestaShop/PrestaShop
Cc: Tony Partridge; Mention
Subject: Re: [PrestaShop/PrestaShop] Country list includes all countries from all shop carriers (#12732)

@tonypartridgehttps://github.com/tonypartridge, in your case, all countries are displayed because they are enabled in all shops, which is normal behavior.
But, in my case, I edited the access of countries for each shop => so, in the FO not all the shops are displayed.
@marionfhttps://github.com/marionf, what do you think?
Thanks!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/PrestaShop/PrestaShop/issues/12732#issuecomment-467882954, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABVgloFVkSMmfbt87hJeerTc78_IGBBYks5vRpatgaJpZM4bTag3.

@tonypartridge yes, you are right it's a multistore issue.
Indeed, you can avoid this issue with the workaround given by @khouloudbelguith

Or you could apply my bug fix as above? If you have ALL countries over different stores that’s a lot of editing you need to do!!

Get Outlook for iOShttps://aka.ms/o0ukef


From: marionf notifications@github.com
Sent: Thursday, February 28, 2019 11:04 am
To: PrestaShop/PrestaShop
Cc: Tony Partridge; Mention
Subject: Re: [PrestaShop/PrestaShop] Country list includes all countries from all shop carriers (#12732)

@tonypartridgehttps://github.com/tonypartridge yes, you are right, this is a multistore issue.
Indeed, you can avoid this issue with the workaround given by @khouloudbelguithhttps://github.com/khouloudbelguith

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/PrestaShop/PrestaShop/issues/12732#issuecomment-468231973, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABVglr1N4zte27b2FSVGsdhecAMY5XK0ks5vR7fDgaJpZM4bTag3.

Was this page helpful?
0 / 5 - 0 ratings