'', 'name' => '', 'price_from' => '', 'price_to' => '', 'weight_from' => '', 'weight_to' => '', 'price' => '', 'type' => 'Single Product', 'countries' => '' ]; //CALL TO API FOR shipping $api_url = '/v2/taxes/'; $countries = ioServer($api_url,''); //Decode Payload if (!empty($countries)){$countries = json_decode($countries,true);}else{$countries = null;} //CountryID mapping $countryMap = array_column($countries, 'country', 'id'); if (isset($_GET['id'])) { //CALL TO API FOR shipping $api_url = '/v2/shipping/id='.$_GET['id']; $shipping = ioServer($api_url,''); //Decode Payload if (!empty($shipping)){$shipping = json_decode($shipping,true);}else{$shipping = null;} $shipping = $shipping[0]; if (isset($_POST['submit'])) { //Update the shipping //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/shipping', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=shipping&success_msg=2'); exit; } } if (isset($_POST['delete'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); var_dump($payload); //API call $responses = ioServer('/v2/shipping', $payload); if ($responses === 'NOK'){ } else { //Redirect and delete product header('Location: index.php?page=shipping&success_msg=3'); exit; } } } else { // Create a new shipping $page = 'Create'; if (isset($_POST['submit'])) { //GET ALL POST DATA $payload = json_encode($_POST , JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/shipping', $payload); if ($responses === 'NOK'){ // DO nothing } else { header('Location: index.php?page=shipping&success_msg=1'); exit; } } } template_header('shipping', 'shipping', 'manage'); $view ='

'.($shipping_h2 ?? 'shipping').'

'.$button_cancel.' '; if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ $view .= ''; } $view .= '
'; $view .= '
'; foreach (explode(',', $shipping['countries']) as $c){ if (empty($c)) continue; { $view .= ' ×'.($countryMap[$c]).' '; } } $view .= '
'; foreach ($countries as $country){ $view .= ''.(${$country['country']} ?? $country['country']).''; } $view .= '
   —   
   —   
'; //Output echo $view; template_footer(); ?>