【问题标题】:Opencart - I want to create a set of radio button in checkout pageOpencart - 我想在结帐页面中创建一组单选按钮
【发布时间】:2013-12-30 11:41:10
【问题描述】:

我想在我的交付方式 - sellegance 主题的结帐页面中创建一组单选按钮。

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

我把代码放在/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>

【问题讨论】:

    标签: php radio-button smarty opencart


    【解决方案1】:

    这里有类似的链接,你可以关注他们。

    Open Cart - Receiving radio value at checkout page

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

    catalog>model>checkout>order::confirm()
    

    【讨论】:

    • 我没有通过链接获得它。那个是 shipping_method.tpl 的吗?你想让我在 catalog>model>checkout>order::confirm() 修改值,我应该在哪里添加值?
    • 其实这只是一个参考链接,显示如何在结帐页面上修改,上面的链接显示在收货地址上添加收音机。当您要求向电子邮件发送附加信息时,catalog>model>checkout>order::confirm() 包含邮件功能,有助于在确认订单结帐后发送电子邮件
    【解决方案2】:

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

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

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

    希望这会有所帮助!

    【讨论】:

      【解决方案3】:
        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
              -------------------------------------------------------------------------------------------------------------
      

      【讨论】:

        猜你喜欢
        • 2014-03-02
        • 2012-04-22
        • 2023-03-17
        • 2012-07-24
        • 1970-01-01
        • 1970-01-01
        • 2013-06-23
        • 2015-10-16
        • 2016-01-15
        相关资源
        最近更新 更多