Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
6 | public function updateFields($fields) |
||
7 | { |
||
8 | $shippingField = $fields->dataFieldByName('ShippingCountry'); |
||
9 | $originalSource = $shippingField->getSource(); |
||
10 | $newSource = $originalSource; |
||
11 | $allowedCountries = CountryPrice_EcommerceCountry::get_sibling_countries(); |
||
12 | $allowedCountries = $allowedCountries->exclude('OnlyShowChildrenInDropdowns', true); |
||
13 | if ($allowedCountries->count()) { |
||
14 | $allowedCountryCodes = $allowedCountries->column('Code'); |
||
15 | foreach ($newSource as $key => $value) { |
||
16 | if (! in_array($key, $allowedCountryCodes)) { |
||
17 | unset($newSource[$key]); |
||
18 | } |
||
19 | } |
||
20 | $shippingField->setSource($newSource); |
||
21 | $js = ' |
||
22 | var CountryPrice_SetCountriesForDelivery_Original = '.Convert::array2json($originalSource).'; |
||
23 | var CountryPrice_SetCountriesForDelivery_New = '.Convert::array2json($newSource).';'; |
||
24 | Requirements::customScript($js, 'CountryPrice_OrderFormAddressExtension_updateFields'); |
||
25 | } |
||
26 | } |
||
27 | } |
||
28 |