Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.11 KB | None | 0 0
  1. public function getTemplateVarsOPC($only_register, $show_authentication)
  2.     {
  3.         $language = $this->context->language;
  4.  
  5.         $countries = Country::getCountries($this->context->language->id, true);
  6.         $countries_js = [];
  7.         $countriesNeedIDNumber = [];
  8.         $countriesNeedZipCode = [];
  9.         $countriesIsoCode = [];
  10.  
  11.         foreach ($countries as $country) {
  12.             $countriesIsoCode[$country['id_country']] = $country['iso_code'];
  13.             $countriesNeedIDNumber[$country['id_country']] = $country['need_identification_number'];
  14.  
  15.             if (! empty($country['zip_code_format'])) {
  16.                 $countriesNeedZipCode[$country['id_country']] = $country['zip_code_format'];
  17.             }
  18.  
  19.             if ($country['contains_states'] == 1 && isset($country['states']) && count($country['states']) > 0) {
  20.                 foreach ($country['states'] as $state) {
  21.                     if ($state['active'] == 1) {
  22.                         $countries_js[$country['id_country']][] = [
  23.                             'id' => $state['id_state'],
  24.                             'name' => $state['name'],
  25.                             'iso_code' => $state['iso_code'],
  26.                         ];
  27.                     }
  28.                 }
  29.             }
  30.         }
  31.  
  32.         $newsletter = false;
  33.         if (Module::isInstalled('blocknewsletter')) {
  34.             $newsletter = (int) Module::getInstanceByName('blocknewsletter')->active;
  35.         }
  36.  
  37.         $is_set_invoice = false;
  38.         if (isset($this->context->cookie->is_set_invoice)) {
  39.             $is_set_invoice = $this->context->cookie->is_set_invoice;
  40.         }
  41.  
  42.         $date_format_language = $this->dateFormartPHPtoJqueryUI($language->date_format_lite);
  43.  
  44.         $opc_social_networks = $this->config_vars['OPC_SOCIAL_NETWORKS'];
  45.         $opc_social_networks = Tools::jsonDecode($opc_social_networks);
  46.  
  47.         $id_country_delivery_default = FieldClass::getDefaultValue('delivery', 'id_country');
  48.         $iso_code_country_delivery_default = Country::getIsoById($id_country_delivery_default);
  49.  
  50.         $id_country_invoice_default = FieldClass::getDefaultValue('invoice', 'id_country');
  51.         $iso_code_country_invoice_default = Country::getIsoById($id_country_invoice_default);
  52.  
  53.         $sql_payment_module = 'SELECT * FROM '._DB_PREFIX_.'opc_ship_to_pay';
  54.         $have_ship_to_pay = false;
  55.  
  56.         //grid steps
  57.         $position_steps = [
  58.             0 => [
  59.                 'classes' => ($only_register ? '' : 'col-md-4 col-sm-5').' col-xs-12 col-12',
  60.                 'rows' => [
  61.                     0 => [
  62.                         'name_step' => 'customer',
  63.                         'classes' => 'col-xs-12 col-12',
  64.                     ],
  65.                 ],
  66.             ],
  67.             1 => [
  68.                 'classes' => 'col-md-8 col-sm-7 col-xs-12 col-12',
  69.                 'rows' => [
  70.                     0 => [
  71.                         'name_step' => 'carrier',
  72.                         'classes' => 'col-xs-12 col-12 col-md-6',
  73.                     ],
  74.                     1 => [
  75.                         'name_step' => 'payment',
  76.                         'classes' => 'col-xs-12 col-12 '.($this->context->cart->isVirtualCart() ? 'col-md-12' : 'col-md-6'),
  77.                     ],
  78.                     2 => [
  79.                         'name_step' => 'review',
  80.                         'classes' => 'col-xs-12 col-12',
  81.                     ],
  82.                 ],
  83.             ],
  84.         ];
  85.  
  86.         $messageValidate = [
  87.             'errorGlobal' => $this->l('This is not a valid.'),
  88.             'errorIsName' => $this->l('This is not a valid name.'),
  89.             'errorIsEmail' => $this->l('This is not a valid email address.'),
  90.             'errorIsPostCode' => $this->l('This is not a valid post code.'),
  91.             'errorIsAddress' => $this->l('This is not a valid address.'),
  92.             'errorIsCityName' => $this->l('This is not a valid city.'),
  93.             'isMessage' => $this->l('This is not a valid message.'),
  94.             'errorIsDniLite' => $this->l('This is not a valid document identifier.'),
  95.             'errorIsPhoneNumber' => $this->l('This is not a valid phone.'),
  96.             'errorIsPasswd' => $this->l('This is not a valid password. Minimum 5 characters.'),
  97.             'errorisBirthDate' => $this->l('This is not a valid birthdate.'),
  98.             'errorisDate' => $this->l('This is not a valid date.'),
  99.             'badUrl' => $this->l('This is not a valid url.').'ex: http://www.domain.com',
  100.             'badInt' => $this->l('This is not a valid.'),
  101.             'notConfirmed' => $this->l('The values do not match.'),
  102.             'lengthTooLongStart' => $this->l('It is only possible enter'),
  103.             'lengthTooShortStart' => $this->l('The input value is shorter than '),
  104.             'lengthBadEnd' => $this->l('characters.'),
  105.             'requiredField' => $this->l('This is a required field.'),
  106.         ];
  107.  
  108.         $register_customer = (bool) Tools::getValue('rc', false);
  109.         if (($register_customer == 1 && ! $this->context->customer->isLogged()) || ($show_authentication && ! $this->context->customer->isLogged())) {
  110.             $register_customer = true;
  111.         }
  112.  
  113.         $templateVars = [
  114.             'messageValidate' => $messageValidate,
  115.             'pts_static_token' => Tools::encrypt('onepagecheckoutps/index'),
  116.             'static_token' => Tools::getToken(false),
  117.             'countries' => $countries_js,
  118.             'countriesNeedIDNumber' => $countriesNeedIDNumber,
  119.             'countriesNeedZipCode' => $countriesNeedZipCode,
  120.             'countriesIsoCode' => $countriesIsoCode,
  121.             'position_steps' => $position_steps,
  122.             'payment_modules_fee' => $this->addModulesExtraFee(),
  123.             'is_virtual_cart' => $this->context->cart->isVirtualCart(),
  124.             'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'),
  125.             'hook_create_account_form' => Hook::exec('displayCustomerAccountForm'),
  126.             'have_ship_to_pay' => (int) empty($have_ship_to_pay),
  127.             'opc_social_networks' => $opc_social_networks,
  128.             'newsletter' => $newsletter,
  129.             'is_set_invoice' => $is_set_invoice,
  130.             'register_customer' => $register_customer,
  131.             'OnePageCheckoutPS' => [
  132.                 'date_format_language' => $date_format_language,
  133.                 'id_country_delivery_default' => $id_country_delivery_default,
  134.                 'id_country_invoice_default' => $id_country_invoice_default,
  135.                 'iso_code_country_delivery_default' => $iso_code_country_delivery_default,
  136.                 'iso_code_country_invoice_default' => $iso_code_country_invoice_default,
  137.                 'IS_GUEST' => (bool) $this->context->customer->isGuest(),
  138.                 'IS_LOGGED' => (bool) $this->context->customer->isLogged(),
  139.                 'iso_code_country_invoice_default' => $iso_code_country_invoice_default,
  140.                 'LANG_ISO_ALLOW' => ['es', 'en', 'ca', 'br', 'eu', 'pt', 'eu', 'mx'],
  141.                 'ONEPAGECHECKOUTPS_DIR' => $this->onepagecheckoutps_dir,
  142.                 'ONEPAGECHECKOUTPS_IMG' => $this->onepagecheckoutps_dir.'views/img/',
  143.                 'PRESTASHOP' => [
  144.                     'CONFIGS' => [
  145.                         'PS_TAX_ADDRESS_TYPE' => Configuration::get('PS_TAX_ADDRESS_TYPE'),
  146.                         'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
  147.                     ],
  148.                 ],
  149.                 'Msg' => [
  150.                     'there_are' => $this->l('There are'),
  151.                     'there_is' => $this->l('There is'),
  152.                     'error' => $this->l('Error'),
  153.                     'errors' => $this->l('Errors'),
  154.                     'field_required' => $this->l('Required'),
  155.                     'dialog_title' => $this->l('Confirm Order'),
  156.                     'no_payment_modules' => $this->l('There are no payment methods available.'),
  157.                     'validating' => $this->l('Validating, please wait'),
  158.                     'error_zipcode' => $this->l('The Zip / Postal code is invalid'),
  159.                     'error_registered_email' => $this->l('An account is already registered with this e-mail'),
  160.                     'error_registered_email_guest' => $this->l('This email is already registered, you can login or fill form again.'),
  161.                     'delivery_billing_not_equal' => $this->l('Delivery address alias cannot be the same as billing address alias'),
  162.                     'errors_trying_process_order' => $this->l('The following error occurred while trying to process the order'),
  163.                     'agree_terms_and_conditions' => $this->l('You must agree to the terms of service before continuing.'),
  164.                     'agree_privacy_policy' => $this->l('You must agree to the privacy policy before continuing.'),
  165.                     'fields_required_to_process_order' => $this->l('You must complete the required information to process your order.'),
  166.                     'check_fields_highlighted' => $this->l('Check the fields that are highlighted and marked with an asterisk.'),
  167.                     'error_number_format' => $this->l('The format of the number entered is not valid.'),
  168.                     'oops_failed' => $this->l('Oops! Failed'),
  169.                     'continue_with_step_3' => $this->l('Continue with step 3.'),
  170.                     'email_required' => $this->l('Email address is required.'),
  171.                     'email_invalid' => $this->l('Invalid e-mail address.'),
  172.                     'password_required' => $this->l('Password is required.'),
  173.                     'password_too_long' => $this->l('Password is too long.'),
  174.                     'password_invalid' => $this->l('Invalid password.'),
  175.                     'addresses_same' => $this->l('You must select a different address for shipping and billing.'),
  176.                     'create_new_address' => $this->l('Are you sure you wish to add a new delivery address? You can use the current address and modify the information.'),
  177.                     'cart_empty' => $this->l('Your shopping cart is empty. You need to refresh the page to continue.'),
  178.                     'dni_spain_invalid' => $this->l('DNI/CIF/NIF is invalid.'),
  179.                     'payment_method_required' => $this->l('Please select a payment method to proceed.'),
  180.                     'shipping_method_required' => $this->l('Please select a shipping method to proceed.'),
  181.                     'select_pickup_point' => $this->l('To select a pick up point is necessary to complete your information and delivery address in the first step.'),
  182.                     'need_select_pickup_point' => $this->l('You need to select on shipping a pickup point to continue with the purchase.'),
  183.                     'select_date_shipping' => $this->l('Please select a date for shipping.'),
  184.                     'confirm_payment_method' => $this->l('Confirmation payment'),
  185.                     'to_determinate' => $this->l('To determinate'),
  186.                     'login_customer' => $this->l('Login'),
  187.                     'processing_purchase' => $this->l('Processing purchase'),
  188.                 ],
  189.             ],
  190.         ];
  191.  
  192.         return $templateVars;
  193.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement