Перейти до вмісту
Пошук в
  • Детальніше...
Шукати результати, які ...
Шукати результати в ...

Ajax Quick Checkout вывод дополнительных полей


designa

Recommended Posts

Как модуль для быстрого заказа используется - Ajax Quick Checkout 6.1.0. Есть только одна проблема в админ панели не отображаются дополнительные поля к заказу. Версия Opencart 2.1.0.1

 

Задача добавить поле - Адрес / Номер отделения службы доставки

 

как альтернативу сейчас использую поле postcode (индекс) изменив название через языковые файлы, но есть проблема в поле postcode стоит проверка на кол-во введенных символов >2 <10, изменял файлы

 

/catalog/controller/checkout/guest.php

/catalog/controller/checkout/payment_address.php   и других но результата нет.

 

Если есть какие-то другие предложения (инструкции) допустим создание дополнительного поля для вывода его в модуле, админ части и письму, буду очень благодарен.

 

Было:

$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);

        if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
            $this->error['postcode'] = $this->language->get('error_postcode');
        }

}

 

Стало:

$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);

        if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 1 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {
            $this->error['postcode'] = $this->language->get('error_postcode');
        }

}

 

Через базу данных менял в order менял значение для order

payment_postcode на varchar(1024) но кол-во максимальных символов не увеличелось

 

Решил использовать комментарий для вывода - Адрес / Номер отделения службы доставки, на стандартном месте перед кнопкой подтвердить заказ он отрабатывает нормально но стоит только в файле

/system/config/d_quickcheckout.php

 

переместить его с

'confirm' => array(
'id' => 'confirm',
'icon' => '',
'display_confirm' => 1,
'sort_order' => 8,
'column' => 4,
'row' => 2,
'width' => '50',
'fields' => array(
'comment' => array(
'id' => 'comment',
'title' => 'text_comments',
'tooltip' => '',
'error' => array(0 => array('min_length' => 1,
'text' => 'error_step_confirm_fields_comment')),
'type' => 'textarea',
'refresh' => '0',
'custom' => 0,
'class' => '',
'sort_order' => 0,
),

}

 

в 

 

'payment_address' => array(
'display' => 1,
'title' => 'text_your_details',
'description' => 'option_register_payment_address_description',
'fields' => array(

}

 

Комментарии перестаю отображаться в заказе админ панели

Скорее всего проблема в том что не отрабатывается переменная комментариев в файле:

catalog/controller/d_quickcheckoutpayment_address.php

 

class ControllerDQuickcheckoutPaymentAddress extends Controller {

public function index($config){

$this->load->model('account/address');
$this->load->model('d_quickcheckout/method');
$this->load->model('d_quickcheckout/address');

$this->document->addScript('catalog/view/javascript/d_quickcheckout/model/payment_address.js');
$this->document->addScript('catalog/view/javascript/d_quickcheckout/view/payment_address.js');

$data['text_address_existing'] = $this->language->get('text_address_existing');
$data['text_address_new'] = $this->language->get('text_address_new');

$data['col'] = $config['account']['guest']['payment_address']['column'];
$data['row'] = $config['account']['guest']['payment_address']['row'];

$json['account'] = $this->session->data['account'];
$json['payment_address'] = $this->session->data['payment_address'];
$json['shipping_required'] = $this->model_d_quickcheckout_method->shippingRequired();

//logged
if($this->customer->isLogged()){

$json['addresses'] = $this->model_d_quickcheckout_address->getAddresses();

if (!empty($this->session->data['payment_address']['address_id'])) {
$json['payment_address']['address_id'] = $this->session->data['payment_address']['address_id'];
} else {
$json['payment_address']['address_id'] = $this->customer->getAddressId();
}
}

$data['json'] = json_encode($json);

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/d_quickcheckout/payment_address.tpl')) {
$template = $this->config->get('config_template') . '/template/d_quickcheckout/payment_address.tpl';
} else {
$template = 'default/template/d_quickcheckout/payment_address.tpl';
}

return $this->load->view($template, $data);
}

public function update(){
$this->load->model('module/d_quickcheckout');
$this->load->model('d_quickcheckout/address');
$this->load->model('d_quickcheckout/method');
$this->load->model('d_quickcheckout/order');
$this->load->model('d_quickcheckout/custom_field');

$json = array();

//payment address
$json = $this->prepare($json);

//shipping address
$json = $this->load->controller('d_quickcheckout/shipping_address/prepare', $json);

//tax
$this->model_d_quickcheckout_address->updateTaxAddress();

//shipping methods
$json = $this->load->controller('d_quickcheckout/shipping_method/prepare', $json);

//payment method - for xshipping (optimization needed)
$json = $this->load->controller('d_quickcheckout/payment_method/prepare', $json);

//totals
$json = $this->load->controller('d_quickcheckout/cart/prepare', $json);
$json['totals'] = $this->session->data['totals'] = $this->model_d_quickcheckout_order->getTotals($total_data, $total, $taxes);
$json['total'] = $this->model_d_quickcheckout_order->getCartTotal($total);

//order
$json['order_id'] = $this->session->data['order_id'] = $this->load->controller('d_quickcheckout/confirm/updateOrder');

//payment
$json = $this->load->controller('d_quickcheckout/payment/prepare', $json);

//statistic
$statistic = array(
'update' => array(
'payment_address' => 1
)
);
$this->model_module_d_quickcheckout->updateStatistic($statistic);

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}

public function prepare($json){
$this->load->model('account/address');
$this->load->model('d_quickcheckout/address');

//post
if(isset($this->request->post['payment_address'])){

//update address data if contry_id or zone_id changed
$this->request->post['payment_address'] = $this->model_d_quickcheckout_address->prepareAddress($this->request->post['payment_address'], $this->session->data['payment_address']);

//if logged in and address_id set and is not empty - fetch address by address_id
if($this->customer->isLogged()){
if($this->request->post['payment_address']['address_id'] !== 'new'
&& $this->request->post['payment_address']['address_id'] !== $this->session->data['payment_address']['address_id']
&& !empty($this->request->post['payment_address']['address_id'])){

$this->request->post['payment_address'] = $this->model_d_quickcheckout_address->getAddress($this->request->post['payment_address']['address_id']);
}
}

$this->load->model('d_quickcheckout/custom_field');

if(isset($this->request->post['payment_address']['custom_field']) && is_array($this->request->post['payment_address']['custom_field'])){
$this->request->post['payment_address'] = array_merge($this->request->post['payment_address'], $this->model_d_quickcheckout_custom_field->setCustomFieldValue($this->request->post['payment_address']['custom_field']));
}
//merge post into session
$this->session->data['payment_address'] = array_merge($this->session->data['payment_address'], $this->request->post['payment_address']);
}

//session
if($this->customer->isLogged()){
if(empty($this->session->data['payment_address']['address_id'])){
$this->session->data['payment_address']['address_id'] = $this->customer->getAddressId();
}

if($this->session->data['payment_address']['address_id'] !== 'new'){
$this->session->data['payment_address']['shipping_address'] = 0;
}
}else{

$this->session->data['guest'] = array(
'customer_group_id' => (!empty($this->request->post['payment_address']['customer_group_id'])) ? $this->request->post['payment_address']['customer_group_id'] : $this->session->data['guest']['customer_group_id'],
'firstname' => (!empty($this->request->post['payment_address']['firstname'])) ? $this->request->post['payment_address']['firstname'] : $this->session->data['guest']['firstname'],
'lastname' => (!empty($this->request->post['payment_address']['lastname'])) ? $this->request->post['payment_address']['lastname'] : $this->session->data['guest']['lastname'],
'email' => (!empty($this->request->post['payment_address']['email'])) ? $this->request->post['payment_address']['email'] : $this->session->data['guest']['email'],
'telephone' => (!empty($this->request->post['payment_address']['telephone'])) ? $this->request->post['payment_address']['telephone'] : $this->session->data['guest']['telephone'],
'fax' => (!empty($this->request->post['payment_address']['fax'])) ? $this->request->post['payment_address']['fax'] : $this->session->data['guest']['fax'],
'custom_field' => (!empty($this->request->post['payment_address']['custom_field'])) ? $this->request->post['payment_address']['custom_field'] : array('account' => array()),
'shipping_address' => (!empty($this->request->post['payment_address']['shipping_address'])) ? $this->request->post['payment_address']['shipping_address'] : $this->session->data['guest']['shipping_address'],
);

}

$json['payment_address'] = $this->session->data['payment_address'];

return $json;

}

}

 

catalog/controller/d_quickcheckout/confirm.php тут переменные для comment

<?php 


class ControllerDQuickcheckoutConfirm extends Controller {


public function index($config){


        $this->document->addScript('catalog/view/javascript/d_quickcheckout/model/confirm.js');
        $this->document->addScript('catalog/view/javascript/d_quickcheckout/view/confirm.js');


        $data['button_confirm'] = $this->language->get('button_confirm');


        $data['col'] = $config['account']['guest']['confirm']['column'];
        $data['row'] = $config['account']['guest']['confirm']['row'];


        $json['account'] = $this->session->data['account'];
        $json['confirm'] = $this->session->data['confirm'];


        $this->load->model('d_quickcheckout/order');
        $json['show_confirm'] = $this->model_d_quickcheckout_order->showConfirm();
        
        $data['json'] = json_encode($json);
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/d_quickcheckout/confirm.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/d_quickcheckout/confirm.tpl', $data);
} else {
return $this->load->view('default/template/d_quickcheckout/confirm.tpl', $data);
}
}


public function updateField(){
        $json['confirm'] = $this->session->data['confirm'] = array_merge($this->session->data['confirm'], $this->request->post['confirm']);
        $this->session->data['comment'] = $this->session->data['confirm']['comment'];


        //statistic
        $this->load->model('module/d_quickcheckout');
        $statistic = array(
            'update' => array(
                'confirm' => 1
            )
        );
        $this->model_module_d_quickcheckout->updateStatistic($statistic);


        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }


    public function update(){
        $json = array();
        $this->load->model('account/address');
        $this->load->model('module/d_quickcheckout');
        $this->load->model('d_quickcheckout/address');


        if($this->customer->isLogged()){
            if($this->session->data['payment_address']['address_id'] == 'new'){
                $json['payment_address']['address_id'] = $this->session->data['payment_address']['address_id'] = $this->model_account_address->addAddress($this->session->data['payment_address']);
            }
            if($this->model_d_quickcheckout_address->showShippingAddress()){
                if($this->session->data['shipping_address']['address_id'] == 'new'){
                    $json['shipping_address']['address_id'] = $this->session->data['shipping_address']['address_id'] = $this->model_account_address->addAddress($this->session->data['shipping_address']);
                }
            }
            
        }else{
            if($this->session->data['account'] == 'register'){


                $this->load->model('account/customer');
                $this->model_account_customer->addCustomer($this->session->data['payment_address']);


                if($this->customer->login($this->session->data['payment_address']['email'], $this->session->data['payment_address']['password'])){
                    $json['account'] = $this->session->data['account'] = 'logged';
                }
            }


        }


        $json['order_id'] = $this->session->data['order_id'] = $this->updateOrder();


        //statistic
        $statistic = array(
            'click' => array(
                'confirm' => 1
            )
        );
        $this->model_module_d_quickcheckout->updateStatistic($statistic);


        $this->response->addHeader('Content-Type: application/json');
        $this->response->setOutput(json_encode($json));
    }


    public function updateOrder(){
        $order_data = array();


        $order_data['totals'] = array();
        $total = 0;
        $taxes = $this->cart->getTaxes();


        $this->load->model('extension/extension');


        $sort_order = array();


        $results = $this->model_extension_extension->getExtensions('total');


        foreach ($results as $key => $value) {
            $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
        }


        array_multisort($sort_order, SORT_ASC, $results);


        foreach ($results as $result) {
            if ($this->config->get($result['code'] . '_status')) {
                $this->load->model('total/' . $result['code']);


                $this->{'model_total_' . $result['code']}->getTotal($order_data['totals'], $total, $taxes);
            }
        }


        $sort_order = array();


        foreach ($order_data['totals'] as $key => $value) {
            $sort_order[$key] = $value['sort_order'];
        }


        array_multisort($sort_order, SORT_ASC, $order_data['totals']);


        $this->load->language('checkout/checkout');


        $order_data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
        $order_data['store_id'] = $this->config->get('config_store_id');
        $order_data['store_name'] = $this->config->get('config_name');


        if ($order_data['store_id']) {
            $order_data['store_url'] = $this->config->get('config_url');
        } else {
            $order_data['store_url'] = HTTP_SERVER;
        }


        if ($this->customer->isLogged()) {
            $this->load->model('account/customer');


            $customer_info = $this->model_account_customer->getCustomer($this->customer->getId());


            $order_data['customer_id'] = $this->customer->getId();
            $order_data['customer_group_id'] = $customer_info['customer_group_id'];
            $order_data['firstname'] = $customer_info['firstname'];
            $order_data['lastname'] = $customer_info['lastname'];
            $order_data['email'] = $customer_info['email'];
            $order_data['telephone'] = $customer_info['telephone'];
            $order_data['fax'] = $customer_info['fax'];
            $order_data['custom_field'] = unserialize($customer_info['custom_field']);
        } elseif (isset($this->session->data['guest'])) {
            $order_data['customer_id'] = 0;
            $order_data['customer_group_id'] = $this->session->data['guest']['customer_group_id'];
            $order_data['firstname'] = $this->session->data['guest']['firstname'];
            $order_data['lastname'] = $this->session->data['guest']['lastname'];
            $order_data['email'] = $this->session->data['guest']['email'];
            $order_data['telephone'] = $this->session->data['guest']['telephone'];
            $order_data['fax'] = $this->session->data['guest']['fax'];
            $order_data['custom_field'] = $this->session->data['guest']['custom_field'];
        }


        $order_data['payment_firstname'] = $this->session->data['payment_address']['firstname'];
        $order_data['payment_lastname'] = $this->session->data['payment_address']['lastname'];
        $order_data['payment_company'] = $this->session->data['payment_address']['company'];
        $order_data['payment_address_1'] = $this->session->data['payment_address']['address_1'];
        $order_data['payment_address_2'] = $this->session->data['payment_address']['address_2'];
        $order_data['payment_city'] = $this->session->data['payment_address']['city'];
        $order_data['payment_postcode'] = $this->session->data['payment_address']['postcode'];
        $order_data['payment_zone'] = $this->session->data['payment_address']['zone'];
        $order_data['payment_zone_id'] = $this->session->data['payment_address']['zone_id'];
        $order_data['payment_country'] = $this->session->data['payment_address']['country'];
        $order_data['payment_country_id'] = $this->session->data['payment_address']['country_id'];
        $order_data['payment_address_format'] = $this->session->data['payment_address']['address_format'];
        $order_data['payment_custom_field'] = (isset($this->session->data['payment_address']['custom_field']['address']) ? $this->session->data['payment_address']['custom_field']['address'] : array());


        if (isset($this->session->data['payment_method']['title'])) {
            $order_data['payment_method'] = $this->session->data['payment_method']['title'];
        } else {
            $order_data['payment_method'] = '';
        }


        if (isset($this->session->data['payment_method']['code'])) {
            $order_data['payment_code'] = $this->session->data['payment_method']['code'];
        } else {
            $order_data['payment_code'] = '';
        }


        if ($this->cart->hasShipping()) {
            $order_data['shipping_firstname'] = $this->session->data['shipping_address']['firstname'];
            $order_data['shipping_lastname'] = $this->session->data['shipping_address']['lastname'];
            $order_data['shipping_company'] = $this->session->data['shipping_address']['company'];
            $order_data['shipping_address_1'] = $this->session->data['shipping_address']['address_1'];
            $order_data['shipping_address_2'] = $this->session->data['shipping_address']['address_2'];
            $order_data['shipping_city'] = $this->session->data['shipping_address']['city'];
            $order_data['shipping_postcode'] = $this->session->data['shipping_address']['postcode'];
            $order_data['shipping_zone'] = $this->session->data['shipping_address']['zone'];
            $order_data['shipping_zone_id'] = $this->session->data['shipping_address']['zone_id'];
            $order_data['shipping_country'] = $this->session->data['shipping_address']['country'];
            $order_data['shipping_country_id'] = $this->session->data['shipping_address']['country_id'];
            $order_data['shipping_address_format'] = $this->session->data['shipping_address']['address_format'];
            $order_data['shipping_custom_field'] = (isset($this->session->data['shipping_address']['custom_field']['address']) ? $this->session->data['shipping_address']['custom_field']['address'] : array());


            if (isset($this->session->data['shipping_method']['title'])) {
                $order_data['shipping_method'] = $this->session->data['shipping_method']['title'];
            } else {
                $order_data['shipping_method'] = '';
            }


            if (isset($this->session->data['shipping_method']['code'])) {
                $order_data['shipping_code'] = $this->session->data['shipping_method']['code'];
            } else {
                $order_data['shipping_code'] = '';
            }
        } else {
            $order_data['shipping_firstname'] = '';
            $order_data['shipping_lastname'] = '';
            $order_data['shipping_company'] = '';
            $order_data['shipping_address_1'] = '';
            $order_data['shipping_address_2'] = '';
            $order_data['shipping_city'] = '';
            $order_data['shipping_postcode'] = '';
            $order_data['shipping_zone'] = '';
            $order_data['shipping_zone_id'] = '';
            $order_data['shipping_country'] = '';
            $order_data['shipping_country_id'] = '';
            $order_data['shipping_address_format'] = '';
            $order_data['shipping_custom_field'] = array();
            $order_data['shipping_method'] = '';
            $order_data['shipping_code'] = '';
        }


        $order_data['products'] = array();


        foreach ($this->cart->getProducts() as $product) {
            $option_data = array();


            foreach ($product['option'] as $option) {
                $option_data[] = array(
                    'product_option_id'       => $option['product_option_id'],
                    'product_option_value_id' => $option['product_option_value_id'],
                    'option_id'               => $option['option_id'],
                    'option_value_id'         => $option['option_value_id'],
                    'name'                    => $option['name'],
                    'value'                   => $option['value'],
                    'type'                    => $option['type']
                );
            }


            $order_data['products'][] = array(
                'product_id' => $product['product_id'],
                'name'       => $product['name'],
                'model'      => $product['model'],
                'option'     => $option_data,
                'download'   => $product['download'],
                'quantity'   => $product['quantity'],
                'subtract'   => $product['subtract'],
                'price'      => $product['price'],
                'total'      => $product['total'],
                'tax'        => $this->tax->getTax($product['price'], $product['tax_class_id']),
                'reward'     => $product['reward']
            );
        }


        // Gift Voucher
        $order_data['vouchers'] = array();


        if (!empty($this->session->data['vouchers'])) {
            foreach ($this->session->data['vouchers'] as $voucher) {
                $order_data['vouchers'][] = array(
                    'description'      => $voucher['description'],
                    'code'             => substr(md5(mt_rand()), 0, 10),
                    'to_name'          => $voucher['to_name'],
                    'to_email'         => $voucher['to_email'],
                    'from_name'        => $voucher['from_name'],
                    'from_email'       => $voucher['from_email'],
                    'voucher_theme_id' => $voucher['voucher_theme_id'],
                    'message'          => $voucher['message'],
                    'amount'           => $voucher['amount']
                );
            }
        }


        $order_data['comment'] = $this->session->data['comment'];
        $order_data['total'] = $total;


        if (isset($this->request->cookie['tracking'])) {
            $order_data['tracking'] = $this->request->cookie['tracking'];


            $subtotal = $this->cart->getSubTotal();


            // Affiliate
            $this->load->model('affiliate/affiliate');


            $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);


            if ($affiliate_info) {
                $order_data['affiliate_id'] = $affiliate_info['affiliate_id'];
                $order_data['commission'] = ($subtotal / 100) * $affiliate_info['commission'];
            } else {
                $order_data['affiliate_id'] = 0;
                $order_data['commission'] = 0;
            }


            // Marketing
            $this->load->model('checkout/marketing');


            $marketing_info = $this->model_checkout_marketing->getMarketingByCode($this->request->cookie['tracking']);


            if ($marketing_info) {
                $order_data['marketing_id'] = $marketing_info['marketing_id'];
            } else {
                $order_data['marketing_id'] = 0;
            }
        } else {
            $order_data['affiliate_id'] = 0;
            $order_data['commission'] = 0;
            $order_data['marketing_id'] = 0;
            $order_data['tracking'] = '';
        }


        $order_data['language_id'] = $this->config->get('config_language_id');
        $order_data['currency_id'] = $this->currency->getId();
        $order_data['currency_code'] = $this->currency->getCode();
        $order_data['currency_value'] = $this->currency->getValue($this->currency->getCode());
        $order_data['ip'] = $this->request->server['REMOTE_ADDR'];


        if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
            $order_data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
        } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
            $order_data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
        } else {
            $order_data['forwarded_ip'] = '';
        }


        if (isset($this->request->server['HTTP_USER_AGENT'])) {
            $order_data['user_agent'] = $this->request->server['HTTP_USER_AGENT'];
        } else {
            $order_data['user_agent'] = '';
        }


        if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) {
            $order_data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
        } else {
            $order_data['accept_language'] = '';
        }
        $this->load->model('d_quickcheckout/order');
        return $this->model_d_quickcheckout_order->updateOrder($this->session->data['order_id'], $order_data);
    }
}

}

Надіслати
Поділитися на інших сайтах


Створіть аккаунт або увійдіть для коментування

Ви повинні бути користувачем, щоб залишити коментар

Створити обліковий запис

Зареєструйтеся для отримання облікового запису. Це просто!

Зареєструвати аккаунт

Вхід

Уже зареєстровані? Увійдіть тут.

Вхід зараз
  • Зараз на сторінці   0 користувачів

    • Ні користувачів, які переглядиють цю сторінку

×
×
  • Створити...

Important Information

На нашому сайті використовуються файли cookie і відбувається обробка деяких персональних даних користувачів, щоб поліпшити користувальницький інтерфейс. Щоб дізнатися для чого і які персональні дані ми обробляємо перейдіть за посиланням . Якщо Ви натиснете «Я даю згоду», це означає, що Ви розумієте і приймаєте всі умови, зазначені в цьому Повідомленні про конфіденційність.