Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getTemplateVarsOPC($only_register, $show_authentication)
- {
- $language = $this->context->language;
- $countries = Country::getCountries($this->context->language->id, true);
- $countries_js = [];
- $countriesNeedIDNumber = [];
- $countriesNeedZipCode = [];
- $countriesIsoCode = [];
- foreach ($countries as $country) {
- $countriesIsoCode[$country['id_country']] = $country['iso_code'];
- $countriesNeedIDNumber[$country['id_country']] = $country['need_identification_number'];
- if (! empty($country['zip_code_format'])) {
- $countriesNeedZipCode[$country['id_country']] = $country['zip_code_format'];
- }
- if ($country['contains_states'] == 1 && isset($country['states']) && count($country['states']) > 0) {
- foreach ($country['states'] as $state) {
- if ($state['active'] == 1) {
- $countries_js[$country['id_country']][] = [
- 'id' => $state['id_state'],
- 'name' => $state['name'],
- 'iso_code' => $state['iso_code'],
- ];
- }
- }
- }
- }
- $newsletter = false;
- if (Module::isInstalled('blocknewsletter')) {
- $newsletter = (int) Module::getInstanceByName('blocknewsletter')->active;
- }
- $is_set_invoice = false;
- if (isset($this->context->cookie->is_set_invoice)) {
- $is_set_invoice = $this->context->cookie->is_set_invoice;
- }
- $date_format_language = $this->dateFormartPHPtoJqueryUI($language->date_format_lite);
- $opc_social_networks = $this->config_vars['OPC_SOCIAL_NETWORKS'];
- $opc_social_networks = Tools::jsonDecode($opc_social_networks);
- $id_country_delivery_default = FieldClass::getDefaultValue('delivery', 'id_country');
- $iso_code_country_delivery_default = Country::getIsoById($id_country_delivery_default);
- $id_country_invoice_default = FieldClass::getDefaultValue('invoice', 'id_country');
- $iso_code_country_invoice_default = Country::getIsoById($id_country_invoice_default);
- $sql_payment_module = 'SELECT * FROM '._DB_PREFIX_.'opc_ship_to_pay';
- $have_ship_to_pay = false;
- //grid steps
- $position_steps = [
- 0 => [
- 'classes' => ($only_register ? '' : 'col-md-4 col-sm-5').' col-xs-12 col-12',
- 'rows' => [
- 0 => [
- 'name_step' => 'customer',
- 'classes' => 'col-xs-12 col-12',
- ],
- ],
- ],
- 1 => [
- 'classes' => 'col-md-8 col-sm-7 col-xs-12 col-12',
- 'rows' => [
- 0 => [
- 'name_step' => 'carrier',
- 'classes' => 'col-xs-12 col-12 col-md-6',
- ],
- 1 => [
- 'name_step' => 'payment',
- 'classes' => 'col-xs-12 col-12 '.($this->context->cart->isVirtualCart() ? 'col-md-12' : 'col-md-6'),
- ],
- 2 => [
- 'name_step' => 'review',
- 'classes' => 'col-xs-12 col-12',
- ],
- ],
- ],
- ];
- $messageValidate = [
- 'errorGlobal' => $this->l('This is not a valid.'),
- 'errorIsName' => $this->l('This is not a valid name.'),
- 'errorIsEmail' => $this->l('This is not a valid email address.'),
- 'errorIsPostCode' => $this->l('This is not a valid post code.'),
- 'errorIsAddress' => $this->l('This is not a valid address.'),
- 'errorIsCityName' => $this->l('This is not a valid city.'),
- 'isMessage' => $this->l('This is not a valid message.'),
- 'errorIsDniLite' => $this->l('This is not a valid document identifier.'),
- 'errorIsPhoneNumber' => $this->l('This is not a valid phone.'),
- 'errorIsPasswd' => $this->l('This is not a valid password. Minimum 5 characters.'),
- 'errorisBirthDate' => $this->l('This is not a valid birthdate.'),
- 'errorisDate' => $this->l('This is not a valid date.'),
- 'badUrl' => $this->l('This is not a valid url.').'ex: http://www.domain.com',
- 'badInt' => $this->l('This is not a valid.'),
- 'notConfirmed' => $this->l('The values do not match.'),
- 'lengthTooLongStart' => $this->l('It is only possible enter'),
- 'lengthTooShortStart' => $this->l('The input value is shorter than '),
- 'lengthBadEnd' => $this->l('characters.'),
- 'requiredField' => $this->l('This is a required field.'),
- ];
- $register_customer = (bool) Tools::getValue('rc', false);
- if (($register_customer == 1 && ! $this->context->customer->isLogged()) || ($show_authentication && ! $this->context->customer->isLogged())) {
- $register_customer = true;
- }
- $templateVars = [
- 'messageValidate' => $messageValidate,
- 'pts_static_token' => Tools::encrypt('onepagecheckoutps/index'),
- 'static_token' => Tools::getToken(false),
- 'countries' => $countries_js,
- 'countriesNeedIDNumber' => $countriesNeedIDNumber,
- 'countriesNeedZipCode' => $countriesNeedZipCode,
- 'countriesIsoCode' => $countriesIsoCode,
- 'position_steps' => $position_steps,
- 'payment_modules_fee' => $this->addModulesExtraFee(),
- 'is_virtual_cart' => $this->context->cart->isVirtualCart(),
- 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'),
- 'hook_create_account_form' => Hook::exec('displayCustomerAccountForm'),
- 'have_ship_to_pay' => (int) empty($have_ship_to_pay),
- 'opc_social_networks' => $opc_social_networks,
- 'newsletter' => $newsletter,
- 'is_set_invoice' => $is_set_invoice,
- 'register_customer' => $register_customer,
- 'OnePageCheckoutPS' => [
- 'date_format_language' => $date_format_language,
- 'id_country_delivery_default' => $id_country_delivery_default,
- 'id_country_invoice_default' => $id_country_invoice_default,
- 'iso_code_country_delivery_default' => $iso_code_country_delivery_default,
- 'iso_code_country_invoice_default' => $iso_code_country_invoice_default,
- 'IS_GUEST' => (bool) $this->context->customer->isGuest(),
- 'IS_LOGGED' => (bool) $this->context->customer->isLogged(),
- 'iso_code_country_invoice_default' => $iso_code_country_invoice_default,
- 'LANG_ISO_ALLOW' => ['es', 'en', 'ca', 'br', 'eu', 'pt', 'eu', 'mx'],
- 'ONEPAGECHECKOUTPS_DIR' => $this->onepagecheckoutps_dir,
- 'ONEPAGECHECKOUTPS_IMG' => $this->onepagecheckoutps_dir.'views/img/',
- 'PRESTASHOP' => [
- 'CONFIGS' => [
- 'PS_TAX_ADDRESS_TYPE' => Configuration::get('PS_TAX_ADDRESS_TYPE'),
- 'PS_GUEST_CHECKOUT_ENABLED' => Configuration::get('PS_GUEST_CHECKOUT_ENABLED'),
- ],
- ],
- 'Msg' => [
- 'there_are' => $this->l('There are'),
- 'there_is' => $this->l('There is'),
- 'error' => $this->l('Error'),
- 'errors' => $this->l('Errors'),
- 'field_required' => $this->l('Required'),
- 'dialog_title' => $this->l('Confirm Order'),
- 'no_payment_modules' => $this->l('There are no payment methods available.'),
- 'validating' => $this->l('Validating, please wait'),
- 'error_zipcode' => $this->l('The Zip / Postal code is invalid'),
- 'error_registered_email' => $this->l('An account is already registered with this e-mail'),
- 'error_registered_email_guest' => $this->l('This email is already registered, you can login or fill form again.'),
- 'delivery_billing_not_equal' => $this->l('Delivery address alias cannot be the same as billing address alias'),
- 'errors_trying_process_order' => $this->l('The following error occurred while trying to process the order'),
- 'agree_terms_and_conditions' => $this->l('You must agree to the terms of service before continuing.'),
- 'agree_privacy_policy' => $this->l('You must agree to the privacy policy before continuing.'),
- 'fields_required_to_process_order' => $this->l('You must complete the required information to process your order.'),
- 'check_fields_highlighted' => $this->l('Check the fields that are highlighted and marked with an asterisk.'),
- 'error_number_format' => $this->l('The format of the number entered is not valid.'),
- 'oops_failed' => $this->l('Oops! Failed'),
- 'continue_with_step_3' => $this->l('Continue with step 3.'),
- 'email_required' => $this->l('Email address is required.'),
- 'email_invalid' => $this->l('Invalid e-mail address.'),
- 'password_required' => $this->l('Password is required.'),
- 'password_too_long' => $this->l('Password is too long.'),
- 'password_invalid' => $this->l('Invalid password.'),
- 'addresses_same' => $this->l('You must select a different address for shipping and billing.'),
- '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.'),
- 'cart_empty' => $this->l('Your shopping cart is empty. You need to refresh the page to continue.'),
- 'dni_spain_invalid' => $this->l('DNI/CIF/NIF is invalid.'),
- 'payment_method_required' => $this->l('Please select a payment method to proceed.'),
- 'shipping_method_required' => $this->l('Please select a shipping method to proceed.'),
- 'select_pickup_point' => $this->l('To select a pick up point is necessary to complete your information and delivery address in the first step.'),
- 'need_select_pickup_point' => $this->l('You need to select on shipping a pickup point to continue with the purchase.'),
- 'select_date_shipping' => $this->l('Please select a date for shipping.'),
- 'confirm_payment_method' => $this->l('Confirmation payment'),
- 'to_determinate' => $this->l('To determinate'),
- 'login_customer' => $this->l('Login'),
- 'processing_purchase' => $this->l('Processing purchase'),
- ],
- ],
- ];
- return $templateVars;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement