public static function validate_settings($settings, $defaults) { if (isset($settings["shipping_settings"]["weight_ids"]) && is_array($settings["shipping_settings"]["weight_ids"])) { $w = $settings["shipping_settings"]["weight"]; foreach (array_unique($settings["shipping_settings"]["weight_ids"]) as $weight_id) { $to_val = $w["to_weight_" . $weight_id]; if (isset($to_val) && intval($to_val) > 0) { $regions = parent::get_shipping_regions(); $region_prices = array(); foreach ($regions as $region_code => $region_data) { $input = "shipping_weight_" . $region_code . "_" . $weight_id; if (isset($w[$input]) && trim($w[$input]) != "") { $region_prices[$region_code] = intval($w[$input]); } } if (count($region_prices) == count($regions)) { $weights[] = array("to_weight" => $weight["to_weight_" . $weight_id], "regions" => $region_prices); } } } } else { $weights = $defaults["shipping_settings"]["weights"]; } usort($weights, array(__CLASS__, 'put_in_order')); $settings["shipping_settings"]["weights"] = $weights; unset($settings["shipping_settings"]["weight_ids"]); unset($settings["shipping_settings"]["weight"]); return $settings; }
/** * helper function to determine whether a customer is liable to pay VAT */ private static function customer_pays_vat() { if (isset($_SESSION["shipping_data"]["address"]) && isset($_SESSION["shipping_data"]["address"]["country"]) && SimplePayPalPluginShipping::is_valid_country_code($_SESSION["shipping_data"]["address"]["country"])) { $region = SimplePayPalPluginShipping::get_region_for_country($_SESSION["shipping_data"]["address"]["country"]); if ($region === 'uk') { return true; } else { if ($region === 'eu') { if (!isset($_SESSION["vat_number"]) || !self::is_valid_vat_number($_SESSION["vat_number"])) { return true; } } } } return true; }