繁体   English   中英

opencart结帐页面中的单选按钮

[英]Radio button in checkout page of opencart

我是php和opencart的新手。 但正计划设置我的在线商店。 我在opencart的“签出”页面中创建了一个选择交付时隙的选项。 如下图所示:

在此处输入图片说明

所以,我开始写一个vqmod来达到这个目的,但是坚持如何在数据库中存储值:我的xml看起来像这样:

<modification>
<id>Salutation Field Modification</id>
<version>1</version>
<vqmver>1.0.8</vqmver>
<author>maca</author>
<file name="catalog/view/theme/bigshop/template/checkout/shipping_method.tpl">
    <operation>
        <search position="before"><![CDATA[
            <p><?php echo $text_shipping_method; ?></p>
        ]]></search>
        <add><![CDATA[
            <p><?php echo $text_shipping_timeslot; ?></p>
            <table class="radio">

      <tr>
        <td colspan="3"><b><?php echo "Delivery time slot"; ?></b></td>
      </tr>
      <tr class="highlight">
        <td>
          <input type="radio" name="shipping_timeslot" value="><?php echo $ship_slot_one; ?></" id="morning?>" checked="checked"/><?php echo $ship_slot_one; ?></br>
          <input type="radio" name="shipping_timeslot" value="><?php echo $ship_slot_two; ?></" id="afternoon?>"/><?php echo $ship_slot_two; ?></br>
          <input type="radio" name="shipping_timeslot" value="><?php echo $ship_slot_three; ?></" id="evening?>"/><?php echo $ship_slot_three; ?></br>
          <input type="radio" name="shipping_timeslot" value="><?php echo $ship_slot_four; ?></" id="night?>"/><?php echo $ship_slot_four; ?></br>
        </td>
      </tr>
      <tr>
        <td colspan="3"></td>
      </tr>
      </table>
        ]]></add>
    </operation>
</file>
<file name="catalog/language/english/checkout/checkout.php">
    <operation>
        <search position="before"><![CDATA[
            $_['text_shipping_method']           = 'Please select the preferred shipping method to use on this order.';
        ]]></search>
        <add><![CDATA[
            $_['text_shipping_timeslot']           = 'Please select the preferred shipping time slot.';
            $_['ship_slot_one']           = 'Morning';
            $_['ship_slot_two']           = 'Afternoon';
            $_['ship_slot_three']           = 'Evening';
            $_['ship_slot_four']           = 'Night';
        ]]></add>
    </operation>
</file>

   <file name="catalog/controller/checkout/shipping_method.php">
       <operation>
           <search position="before"><![CDATA[
               $this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
           ]]></search>
           <add><![CDATA[
               $this->data['text_shipping_timeslot'] = $this->language->get('text_shipping_timeslot');
               $this->data['ship_slot_one'] = $this->language->get('ship_slot_one');
               $this->data['ship_slot_two'] = $this->language->get('ship_slot_two');
               $this->data['ship_slot_three'] = $this->language->get('ship_slot_three');
               $this->data['ship_slot_four'] = $this->language->get('ship_slot_four');
           ]]></add>
       </operation>

   </file>

</modification>

请指导我。

正如弗洛里斯(Floris)提到的-输入的部分中有>号,我猜这是不正确的。 另外,最好将输入的标签放入真实的HTML 标签中,以便在单击该标签时选中该复选框/收音机(直接单击小复选框/收音机不太舒服)。

现在到您的保存问题:我建议按表order创建一个新的DB列,称为shipping_time_slot ,类型为enum('opt1', 'opt2', 'etc.') 您将在此处存储您选择的运输时间段。

现在,对于控制器,您必须(通过vQmod)修改catalog/controller/checkout/shipping_method.php (此外,您应该对Guest checkout进行非常相同的修改-应用不同的文件)并从POST接收shipping_timeslot值并将其与所有其他运输信息一起保存到会话中。

最后(但不是真的),您将不得不修改模型catalog/model/checkout/order.php和方法addOrder()以将shipping_timeslot值保存到数据库中。

那应该只是用于存储到数据库中。

但是,请记住,还应该扩展后端(管理),以便能够从数据库加载shipping_timeslot值并在订单详细信息中显示它们-这意味着至少要修改以下文件:

  • admin/controller/sale/order.php
  • admin/model/sale/order.php (可能不需要)
  • admin/language/<YOUR_LANG>/sale/order.php为shipping_timeslot添加新翻译
  • admin/view/template/sale/order_info.tpladmin/view/template/sale/order_form.tpl
  Here is full solution....
  Open file..
        /*** TIME SLOT OPENCART CODING ***/

        C:\wamp\www\OC\catalog\controller\checkout\shipping_method.php

        1)
        Find :- 
        $this->session->data['comment'] = strip_tags($this->request->post['comment']);

        After that copy and paste :-
        $this->session->data['shipping_timeslot'] = $this->request->post['shipping_timeslot'];
        -------------------------------------------------------------------------------------------------------------
        2)
        Find :- 
        $this->data['text_shipping_method'] = $this->language->get('text_shipping_method');

        After that copy and paste :-
        $this->data['text_shipping_timeslot'] = $this->language->get('text_shipping_timeslot');
        $this->data['ship_slot_one'] = $this->language->get('ship_slot_one');
        $this->data['ship_slot_two'] = $this->language->get('ship_slot_two');
        $this->data['ship_slot_three'] = $this->language->get('ship_slot_three');
        $this->data['ship_slot_four'] = $this->language->get('ship_slot_four');
        -------------------------------------------------------------------------------------------------------------
        3)
        Find :- 
        if (isset($this->session->data['comment'])) {
        $this->data['comment'] = $this->session->data['comment'];
        } else {
        $this->data['comment'] = '';
        }

        After that copy and paste :-
        if (isset($this->session->data['shipping_timeslot'])) {
        $this->data['shipping_timeslot'] = $this->session->data['shipping_timeslot'];
        } else {
        $this->data['shipping_timeslot'] = '';
        }
        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\catalog\model\checkout\order.php

        1)
        Find :-
        commission = '" . (float)$data['commission'] . "'

        After that copy and paste :-
        shipping_time_slot = '" . $this->db->escape($data['shipping_timeslot']) . "',

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\catalog\language\english\checkout\checkout.php

        1)
        Find :-
        $_['text_length']

        After that copy and paste :-
        $_['text_shipping_timeslot']           = 'Please select the preferred shipping time slot.';
        $_['ship_slot_one']           = 'Morning';
        $_['ship_slot_two']           = 'Afternoon';
        $_['ship_slot_three']           = 'Evening';
        $_['ship_slot_four']           = 'Night';

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\catalog\view\theme\vitalia\template\checkout\shipping_method.tpl

        1)
        Find :-
        <p><?php echo $text_shipping_method; ?></p>

        Above that copy and paste :-
        <p><?php echo $text_shipping_timeslot; ?></p>
        <table class="radio">

            <tr>
                <td colspan="3"><b><?php echo "Delivery time slot"; ?></b></td>
            </tr>
            <tr class="highlight">
                <td>
                    <input type="radio" name="shipping_timeslot" value="<?php echo $ship_slot_one; ?>" id="morning" checked="checked"/><?php echo $ship_slot_one; ?></br>
                    <input type="radio" name="shipping_timeslot" value="<?php echo $ship_slot_two; ?>" id="afternoon"/><?php echo $ship_slot_two; ?></br>
                    <input type="radio" name="shipping_timeslot" value="<?php echo $ship_slot_three; ?>" id="evening"/><?php echo $ship_slot_three; ?></br>
                    <input type="radio" name="shipping_timeslot" value="<?php echo $ship_slot_four; ?>" id="night"/><?php echo $ship_slot_four; ?></br>
                </td>
            </tr>
            <tr>
                <td colspan="3"></td>
            </tr>
        </table>

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\admin\controller\sale\order.php

        1)
        Find :-
        $this->data['store_url'] = $order_info['store_url'];

        Above that copy and paste :-
        $this->data['shipping_time_slot'] = $order_info['shipping_time_slot'];
        -------------------------------------------------------------------------------------------------------------

        2)
        Find :- May be line no. 1580
        $this->data['comment'] = nl2br($order_info['comment']);

        Below that copy and paste :-
        $this->data['shipping_time_slot'] = $order_info['shipping_time_slot'];

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\catalog\controller\checkout\confirm.php

        1)
        Find :-
        $data['comment'] = $this->session->data['comment'];

        Below that copy and paste :-
        $data['shipping_timeslot'] = $this->session->data['shipping_timeslot'];

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\admin\language\english\sale\order.php

        1)
        Find :-
        $_['text_store_name']                         = 'Store Name:';

        Below that copy and paste :-
        $_['text_time_slot']                           = 'Time Slot:';

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\admin\view\template\sale\order_info.tpl

        1)
        Find :-
        <tr>
            <td><?php echo $text_store_name; ?></td>
            <td><?php echo $store_name; ?></td>
        </tr>

        Below that copy and paste :-

        <tr>
            <td><?php echo $text_time_slot; ?></td>
            <td><?php echo $shipping_time_slot ?></td>
        </tr>

        -------------------------------------------------------------------------------------------------------------
        -------------------------------------------------------------------------------------------------------------

        C:\wamp\www\OC\admin\model\sale\order.php

        1)
        Find :-
        'date_modified'           => $order_query->row['date_modified']

        Below that copy and paste :-
        ,
                                        'shipping_time_slot'           => $order_query->row['shipping_time_slot']

        -------------------------------------------------------------------------------------------------------------
                                                                THATS IT
        -------------------------------------------------------------------------------------------------------------

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM