Open Cart - Receiving radio value at checkout page [closed]

眉间皱痕 提交于 2019-12-13 22:11:23

问题


I need help to create a radio box during the checkout. I have no idea how to have the result of the radio box send along with my other information in the checkout page such as billing address and many more.

this is what i do ,

<input type="radio" name="shipping_address" value="existing" id="shipping-address-existing" checked="checked" class="radio inline" />
<b><?php echo $text_delivery2; ?></b>

<input type="radio" name="shipping_address" value="existing" id="shipping-address-existing" checked="checked" class="radio inline" />
<b><?php echo $text_delivery3; ?></b>
</label>

but there is nothing shown. thanks


回答1:


First be specic on question because the checkout page contains list of conditions along with various section (login,register,payment address, payment method, shipping address, shipping method, quick confirm etc)

There are list of action and their regarding template, So you need to change in the regarding file, Suppose you are adding radio button on billing address

Find regarding template file and add radio

//template>checkout>payment_address.tpl 
<input type="radio" name="shipping_address" value="existing1" id="shipping-address-existing" checked="checked" class="radio inline" />
<b><?php echo 'Delivery2'; ?></b>

<input type="radio" name="shipping_address" value="existing2" id="shipping-address-existing" checked="checked" class="radio inline" />
<b><?php echo 'Delivery3'; ?></b>
</label>

Now in checkout page you can see your radio buttons, It uses the ajax method to parse data to function

//in line 350 of template>checkout>checkout.tpl 

you can see a ajax function function

$('#button-payment-address').live('click', function() {
    $.ajax({
        url: 'index.php?route=checkout/payment_address/validate',
        type: 'post',
        data: $('#payment-address input[type=\'text\'], #payment-address input[type=\'password\'], #payment-address input[type=\'checkbox\']:checked, #payment-address input[type=\'radio\']:checked, #payment-address input[type=\'hidden\'], #payment-address select'),
        dataType: 'json',

Here the url repreesnts the controller function

// controller>checkout>payment_address.php and function is validate()

Here you can fetch your radio value $_POST['shipping_address'] because in ajax we have defined type: 'post'

Hope this helps



来源:https://stackoverflow.com/questions/20730799/open-cart-receiving-radio-value-at-checkout-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!