Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress “发送到不同地址”复选框至单选按钮_Wordpress - Fatal编程技术网

Wordpress “发送到不同地址”复选框至单选按钮

Wordpress “发送到不同地址”复选框至单选按钮,wordpress,Wordpress,我想删除“发送到不同地址”复选框,并将其更改为带有“是”和“否”的单选按钮。我找不到任何方法来执行此操作。有什么建议吗 <h3 id="ship-to-different-address"> <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox"> <input id="ship-to-different-address-chec

我想删除“发送到不同地址”复选框,并将其更改为带有“是”和“否”的单选按钮。我找不到任何方法来执行此操作。有什么建议吗

<h3 id="ship-to-different-address">
    <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
        <input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" /> <span><?php _e( 'Ship to a different address?', 'woocommerce' ); ?></span>
    </label>
</h3>


您需要编辑模板文件,
form shipping.php
。在该文件中,更改显示的代码,并执行以下操作

<h3 class="radio-toggle">
    <span><?php _e( 'Ship to a different address?', 'woocommerce' ); ?></span>
    <label class="woocommerce-form__label woocommerce-form__label-for-radio radio" style="margin-left:15%;">
        <input id="ship-to-different-address-radio-yes" class="woocommerce-form__input woocommerce-form__input-radio input-radio" type="radio" name="ship_to_different_address_radio_toggle" value="1" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> /> <?php _e( 'Yes', 'woocommerce' ); ?>
    </label>
    <label class="woocommerce-form__label woocommerce-form__label-for-radio radio" style="margin-left:5%;">
        <input id="ship-to-different-address-radio-no" class="woocommerce-form__input woocommerce-form__input-radio input-radio" type="radio" name="ship_to_different_address_radio_toggle" value="0" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'billing' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> /> <?php _e( 'No', 'woocommerce' ); ?>
    </label>
    <span id="ship-to-different-address"><input id="ship-to-different-address-checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" <?php checked( apply_filters( 'woocommerce_ship_to_different_address_checked', 'shipping' === get_option( 'woocommerce_ship_to_destination' ) ? 1 : 0 ), 1 ); ?> type="checkbox" name="ship_to_different_address" value="1" style="opacity:0;" /></span>
</h3>
这将导致将复选框更改为标签为“是”和“否”的单选按钮。下面是供您参考的屏幕截图。这与扩展和折叠发货地址表单的前一个div的功能一起提供

希望这有帮助


嗨,Yasir,很遗憾,你的问题没有足够的信息让任何人都能给出答案。代码从哪里来?这是定制主题吗?非常感谢你,老板。你救了我的当事人和我的命。。。祝你一切顺利,我还需要你的帮助。。您发送给我的单选按钮脚本不适用于新的wordpress更新。你能帮我一下吗?新闻更新不应该影响你所做的定制。您是否更新了自定义的主题?是的。。是的。。主题不支持它现在该怎么办?你能告诉我主题的名称,它是免费主题还是付费主题吗?
if ( ! function_exists( 'toggle_shipping_address' ) ){
    function toggle_shipping_address(){
        global $post;
        if($post->post_name === 'checkout'){
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($){
            $('.radio-toggle .input-radio').change(function(){
                var curval = ($(this).val() === '0') ? true : false;
                $('#ship-to-different-address-checkbox').prop('checked', curval);
                $('#ship-to-different-address-checkbox').trigger('click');
            });
        });
        </script>
        <?php
        }
    }
}
add_action( 'wp_footer', 'toggle_shipping_address' );