NKoonen / vatchecker

[Prestashop]Checks if customer has a valid VAT number, and then puts the customer a specific group.
https://customs-documents.com
BSD 3-Clause "New" or "Revised" License
34 stars 15 forks source link

Allow selecting shop-disabled countries in settings #30

Closed mcdado closed 1 year ago

mcdado commented 1 year ago

Country::getCountries() doesn't return disabled countries in the shop, and makes them unselectable. This changes allows for that.

mcdado commented 1 year ago

Ok, but pay attention to the fact that a country not only can be set as "inactive" but also "disabled" on a store, which IIRC removes it from the joining table.

mcdado commented 1 year ago

I double checked, and if it is of any use to you, here's why I'll keep using my modified version:

We have two shops in a multishop environment, for two geographical markets. Multishop is a bit of a mess in PrestaShop, since some tables like product_shop have additional information per shop, while country_shop is a simple joining table where disassociating a country from a shop deletes it from that joining table. Setting a country as inactive changes the boolean flag on the country table, but that's something that lives for all shop.

Let's say I have shop A with Italy and shop B with France: they both have to be active, but they are each associated with either one of the two shops.

Country::getCountries() adds a join statement Shop::addSqlAssociation('country', 'c') that links tables country and country_shop. It does not return countries that are not associated with the current shop.

NKoonen commented 1 year ago

You are absolutely right! thanks for the commit 👍