<?php
if (! defined('ABSPATH')) exit;

require_once plugin_dir_path(__FILE__) . '../../helpers/minicomerce_currency.php'; 
function minicomerce_checkout()
{ 
$essential_data = (null !==  get_option(MINICOMERCE_ESSENTIAL)) ? unserialize(get_option(MINICOMERCE_ESSENTIAL)) : null;
$translation_data = (null !==  get_option(MINICOMERCE_TRANSLATIONS)) ? unserialize(get_option(MINICOMERCE_TRANSLATIONS)) : null;

$minicomerce_output = '<div class="minicomerce_wrapper_userData_wrapper_checkout">';
$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_title">';
$minicomerce_output .= '<h1 class="minicomerce_wrapper_userData_wrapper_checkout_title_h1">';
$minicomerce_output .= esc_html(  $essential_data[0]  , "minicomerce" )  ;  
$minicomerce_output .= '</h1>';
$minicomerce_output .= '</div>';
$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_price">';
$minicomerce_output .= '<h3 class="minicomerce_wrapper_userData_wrapper_checkout_price_h3">'; 
$minicomerce_output .= '<i class="minicomerce_wrapper_userData_wrapper_checkout_price_h3_currency">';
$minicomerce_output .=  esc_html( minicomerce_currency()[$essential_data[6]] , "minicomerce");  
$minicomerce_output .= '</i>';
$minicomerce_output .= '<i class="minicomerce_wrapper_userData_wrapper_checkout_price_h3_price">';
$minicomerce_output .=  esc_html( $essential_data[7] , "minicomerce");  
$minicomerce_output .= '</i>'; 
$minicomerce_output .= '</h3>';
$minicomerce_output .= '</div>'; 
$minicomerce_output .= '<span class="minicomerce_wrapper_userData_wrapper_checkout_titleForm">';
$minicomerce_output .=  esc_html(  $translation_data[3] , 'minicomerce');   
$minicomerce_output .= '</span>'; 
$minicomerce_output .= '<form class="minicomerce_wrapper_userData_wrapper_checkout_form">';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_product">';
$minicomerce_output .= '<select name="product" id="product" required>';
$minicomerce_output .= '<option value> select variant</option>';
$variations = explode("," ,$essential_data[4]) ; 

foreach ($variations as $variation) {

$minicomerce_output .= '<option value="' .  esc_html(  $variation , 'minicomerce')  .'" class="minicomerce_wrapper_userData_wrapper_details_variations_ul_li">';
$minicomerce_output .= esc_html(  $variation , "minicomerce");
$minicomerce_output .= '</option>';

}  

$minicomerce_output .= '</select>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_name">';
$minicomerce_output .= '<input type="text" name="name" id="name" placeholder="Name" autocomplete="name" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_surname">';
$minicomerce_output .= '<input type="text" name="surname" id="surname" placeholder="Surname" autocomplete="additional-name" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_tel">';
$minicomerce_output .= '<input type="text" name="tel" id="tel" placeholder="+34 000 000 000" autocomplete="tel" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_city">';
$minicomerce_output .= '<select type="text" name="city" id="city" autocapitalize="country" required> ';
$minicomerce_output .= '<option value> select city</option>';
$variations = explode("," ,$essential_data[5]) ;  
foreach ($variations as $variation) {

$minicomerce_output .= '<option value="' . esc_html(  $variation , 'minicomerce') .'" class="minicomerce_wrapper_userData_wrapper_details_variations_ul_li">';
$minicomerce_output .= esc_html(  $variation , "minicomerce");
$minicomerce_output .= '</option>';
}  

$minicomerce_output .= '</select>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_email">';
$minicomerce_output .= '<input type="mail" name="email" id="mail" placeholder="info@gmail.com" autocomplete="email" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_cp">';
$minicomerce_output .= '<input type="number" name="postalCode" id="cp" placeholder="05333" autocomplete="postal-code" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_address">';
$minicomerce_output .= '<input type="text" name="address" id="address" placeholder="Carrer maragal 45, 3do 2da" autocomplete="street-address" required>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_note">';
$minicomerce_output .= '<textarea name="note" id="note" placeholder="note:"></textarea>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_aceptance">';
$minicomerce_output .= '<input type="checkbox" name="aceptance" id="aceptance" required>';
$minicomerce_output .= '<label for="aceptance">';

$minicomerce_output .= esc_html(  $translation_data[4] , 'minicomerce'); 

if($essential_data[5] !== 'n/a') {

$minicomerce_output .= '<a style="color:' . esc_html(  $essential_data[11] , "minicomerce")  . '" href="' . esc_html(  $essential_data[3] , 'minicomerce' ) .'">';
$minicomerce_output .= esc_html( " ". $translation_data[5] , "minicomerce"); 
$minicomerce_output .= '</a>';


}

$minicomerce_output .= '</label>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_cancel">';
$minicomerce_output .= '<button type="reset" name="reset" id="reset">' . esc_html(  $translation_data[7] , "minicomerce") .'</button>';
$minicomerce_output .= '</div>';

$minicomerce_output .= '<div class="minicomerce_wrapper_userData_wrapper_checkout_form_button">';
$minicomerce_output .= '<button style="background-color:' . esc_html(  $essential_data[11] , "minicomerce")  . '"  type="submit" name="submit" id="submit">' . esc_html(  $translation_data[8] , "minicomerce") . '</button>';
$minicomerce_output .= '</div>';



$minicomerce_output .= '</form>';
$minicomerce_output .= '</div>';

return $minicomerce_output;

}