Opencart - 我想在结帐页面中创建一组单选按钮

时间:2013-12-30 11:41:10

标签: php radio-button smarty opencart

我想在结帐页面上以我的送货方式创建一组单选按钮 - sellegance theme。

我的代码出现在投放方法部分。但问题是我不知道如何从单选按钮接收值。我希望将价值与结账页面中的其他信息一起发送到我的电子邮箱。

我把代码放在/public_html/catalog/view/theme/sellegance/template/checkout/shipping_method.tpl

<label class="inline-radio"><input type="radio" name="delivery_method" value="delivery" id="delivery" checked/> Ship only </label> &nbsp;&nbsp; <label class="inline-radio"> <input type="radio" name="delivery_method" value="delivery2" id="delivery2"/> Ship ready</label> &nbsp;&nbsp; <label class="inline-radio"> <input type="radio" name="delivery_method" value="delivery3" id="delivery3" /> Consult </label>

3 个答案:

答案 0 :(得分:0)

假设您的代码是带有POST方法的表单的一部分,您需要引用$_POST['delivery_method']的值。

您必须修改处理POST数据的相应控制器。它位于catalog/controller/checkout/shipping_method.php。您正在寻找的方法可能是validate() 88 附近。

看看 Stefan Koenen 对另一个问题的回答: Php - testing if a radio button is selected and get the value

希望这有帮助!

答案 1 :(得分:0)

这里有类似的链接,只需按照它们即可。

Open Cart - Receiving radio value at checkout page

对于电子邮件,您需要修改

中的值
catalog>model>checkout>order::confirm()

答案 2 :(得分:0)

  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
        -------------------------------------------------------------------------------------------------------------