[Помогите] Нужно убрать лишние строки с модуля корзины

Тема в разделе "OpenCart", создана пользователем Aleksand_D, 21 сен 2016.

  1. Aleksand_D

    Aleksand_D

    Регистрация:
    19 сен 2016
    Сообщения:
    8
    Симпатии:
    0
    Помогите разобраться, я в коде практически не шарю
    Нужно убрать:
    1.Адрес (продолжение)
    2.Факс
    3. Индекс
    4.ID Компании
    5. Страна

    И сделать не обеязательными:
    1. E-Mail Адрес
    2.Фамилию

    shipping_method.php

    Код:
    <?php
    class ControllerCheckoutShippingMethod extends Controller {
          public function index() {
            $this->language->load('checkout/checkout');
    
            $this->load->model('account/address');
    
            if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) {
                $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
            } else{
                if (isset($this->session->data['shipping_temp']["active"])){
                        if (isset($this->session->data['shipping_temp'][$this->session->data['shipping_temp']["active"]]["data"]))
                        {
                            $shipping_address = $this->session->data['shipping_temp'][$this->session->data['shipping_temp']["active"]]["data"];
                        }
                } else {
                        if (isset($this->session->data['guest'])){
                        $shipping_address = $this->session->data['guest']['shipping'];
                    }
                }
            }
            $first_shipp_code = "";
            if (!empty($shipping_address)) {
                // Shipping Methods
                $quote_data = array();
    
                $this->load->model('setting/extension');
    
                $results = $this->model_setting_extension->getExtensions('shipping');
    
                foreach ($results as $result) {
                    if ($this->config->get($result['code'] . '_status')) {
                        $this->load->model('shipping/' . $result['code']);
    
                        $quote = $this->{'model_shipping_' . $result['code']}->getQuote($shipping_address);
    
                        if ($quote) {
                            $quote_data[$result['code']] = array(
                                'title'      => $quote['title'],
                                'quote'      => $quote['quote'],
                                'sort_order' => $quote['sort_order'],
                                'error'      => $quote['error']
                            );
    
                        }
                    }
                }
    
                $sort_order = array();
    
                foreach ($quote_data as $key => $value) {
                    $sort_order[$key] = $value['sort_order'];
                }
    
                array_multisort($sort_order, SORT_ASC, $quote_data);
    
    
                if (empty($first_shipp_code)&&!empty($quote_data)){
                    reset($quote_data);
                    $first_key = key($quote_data);
                    $first_shipp_code =$quote_data[$first_key]["quote"][key($quote_data[$first_key]["quote"])]['code'];
                }
    
                $this->session->data['shipping_methods'] = $quote_data;
            }
    
            $this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
            $this->data['text_comments'] = $this->language->get('text_comments');
    
            $this->data['button_continue'] = $this->language->get('button_continue');
    
            if (empty($this->session->data['shipping_methods'])) {
                $this->data['error_warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));
            } else {
                $this->data['error_warning'] = '';
            }
    
            if (isset($this->session->data['shipping_methods'])) {
                $this->data['shipping_methods'] = $this->session->data['shipping_methods'];
            } else {
                $this->data['shipping_methods'] = array();
            }
    
            if (isset($this->session->data['shipping_method']['code'])) {
                $this->data['code'] = $this->session->data['shipping_method']['code'];
            } else {
                $this->data['code'] = '';
            }
    
            if ($this->data['code']==''){
                if( ! isset($this->session->data['shipping_method']) && !empty($this->data['shipping_methods'])){
                    if (!empty($first_shipp_code)){
                        $shipping = explode('.', $first_shipp_code);
                        $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
    
                        $this->data['code']==$first_shipp_code;
                    }
    
                }
    
            }
    
    
            if (isset($this->session->data['comment'])) {
                $this->data['comment'] = $this->session->data['comment'];
            } else {
                $this->data['comment'] = '';
            }
    
            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/onestepcheckout/shipping_method.tpl')) {
                $this->template = $this->config->get('config_template') . '/template/onestepcheckout/shipping_method.tpl';
            } else {
                $this->template = 'default/template/onestepcheckout/shipping_method.tpl';
            }
    
            $this->response->setOutput($this->render());
          }
    
        public function validate() {
            $this->language->load('checkout/checkout');
    
            $json = array();
    
            // Validate if shipping is required. If not the customer should not have reached this page.
            if (!$this->cart->hasShipping()) {
                $json['redirect'] = $this->url->link('checkout/checkout', '', 'SSL');
            }
    
            // Validate if shipping address has been set.
            $this->load->model('account/address');
    
            if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) {
                $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
            } elseif (isset($this->session->data['guest'])) {
                $shipping_address = $this->session->data['guest']['shipping'];
            }
    
            if (empty($shipping_address)) {
                $json['redirect'] = $this->url->link('checkout/checkout', '', 'SSL');
            }
    
            // Validate cart has products and has stock.
            if ((!$this->cart->hasProducts() && empty($this->session->data['vouchers'])) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) {
                $json['redirect'] = $this->url->link('checkout/cart');
            }
    
            // Validate minimum quantity requirments.
            $products = $this->cart->getProducts();
    
            foreach ($products as $product) {
                $product_total = 0;
    
                foreach ($products as $product_2) {
                    if ($product_2['product_id'] == $product['product_id']) {
                        $product_total += $product_2['quantity'];
                    }
                }
    
                if ($product['minimum'] > $product_total) {
                    $json['redirect'] = $this->url->link('checkout/cart');
    
                    break;
                }
            }
    
            if (!$json) {
                if (!isset($this->request->post['shipping_method'])) {
                    $json['error']['warning'] = $this->language->get('error_shipping');
                } else {
                    $shipping = explode('.', $this->request->post['shipping_method']);
    
                    if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
                        $json['error']['warning'] = $this->language->get('error_shipping');
                    }
                }
    
                if (!$json) {
                    $shipping = explode('.', $this->request->post['shipping_method']);
    
                    $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
    
                                    if (isset($this->request->post['comment']))
                    $this->session->data['comment'] = strip_tags($this->request->post['comment']);
                }
            }
    
            $this->response->setOutput(json_encode($json));
        }
    }
    ?>

    guest_shipping.tpl

    Код:
    <table class="form">
      <tr>
        <td><span class="required">*</span> <?php echo $entry_firstname; ?></td>
        <td><input type="text" name="firstname" value="<?php echo $firstname; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_lastname; ?></td>
        <td><input type="text" name="lastname" value="<?php echo $lastname; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><?php echo $entry_company; ?></td>
        <td><input type="text" name="company" value="<?php echo $company; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_address_1; ?></td>
        <td><input type="text" name="address_1" value="<?php echo $address_1; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><?php echo $entry_address_2; ?></td>
        <td><input type="text" name="address_2" value="<?php echo $address_2; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_city; ?></td>
        <td><input type="text" name="city" value="<?php echo $city; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><span id="shipping-postcode-required" class="required">*</span> <?php echo $entry_postcode; ?></td>
        <td><input type="text" name="postcode" value="<?php echo $postcode; ?>" class="large-field" /></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_country; ?></td>
        <td><select name="country_id" class="large-field">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($countries as $country) { ?>
            <?php if ($country['country_id'] == $country_id) { ?>
            <option value="<?php echo $country['country_id']; ?>" selected="selected"><?php echo $country['name']; ?></option>
            <?php } else { ?>
            <option value="<?php echo $country['country_id']; ?>"><?php echo $country['name']; ?></option>
            <?php } ?>
            <?php } ?>
          </select></td>
      </tr>
      <tr>
        <td><span class="required">*</span> <?php echo $entry_zone; ?></td>
        <td><select name="zone_id" class="large-field">
          </select></td>
      </tr>
    </table>
    <br />
    <div class="buttons">
      <div class="right"><input type="button" value="<?php echo $button_continue; ?>" id="button-guest-shipping" class="button" /></div>
    </div>
    <script type="text/javascript"><!--
    $('#shipping-address select[name=\'country_id\']').bind('change', function() {
        if (this.value == '') return;
        $.ajax({
            url: 'index.php?route=checkout/checkout/country&country_id=' + this.value,
            dataType: 'json',
            beforeSend: function() {
                $('#shipping-address select[name=\'country_id\']').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
            },
            complete: function() {
                $('.wait').remove();
            },
            success: function(json) {
                if (json['postcode_required'] == '1') {
                    $('#shipping-postcode-required').show();
                } else {
                    $('#shipping-postcode-required').hide();
                }
    
                html = '<option value=""><?php echo $text_select; ?></option>';
    
                if (json['zone'] != '') {
                    for (i = 0; i < json['zone'].length; i++) {
                        html += '<option value="' + json['zone'][i]['zone_id'] + '"';
    
                        if (json['zone'][i]['zone_id'] == '<?php echo $zone_id; ?>') {
                              html += ' selected="selected"';
                        }
    
                        html += '>' + json['zone'][i]['name'] + '</option>';
                    }
                } else {
                    html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
                }
    
                $('#shipping-address select[name=\'zone_id\']').html(html);
            },
            error: function(xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    });
    
    $('#shipping-address select[name=\'country_id\']').trigger('change');
    //--></script>
     
    Последнее редактирование: 21 сен 2016
  2. Dotrox

    Dotrox Команда форума

    Регистрация:
    27 ноя 2012
    Сообщения:
    3.198
    Симпатии:
    1.306
    Это намного сложнее, чем просто что-то выкинуть из шаблона. На стране, например, завязаны геозоны, на которых в свою очередь завязаны оплата с доставкой.

    На все такие вопросы есть один простой и универсальный ответ - Simple.
     
    shede и samuel_L нравится это.