pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

在 Woocommerce 注冊(cè)表中添加條款和條件復(fù)選框

Add a terms and conditions checkbox in Woocommerce registration form(在 Woocommerce 注冊(cè)表中添加條款和條件復(fù)選框)
本文介紹了在 Woocommerce 注冊(cè)表中添加條款和條件復(fù)選框的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

在 woocommerce 注冊(cè)表中,注冊(cè)按鈕前沒(méi)有條款和條件".

有沒(méi)有辦法讓它出現(xiàn)在表單中?

這是

  • 然后保存……大功告成.

  • 獲取注冊(cè)表單上的條款和條件復(fù)選框的代碼:

    //在注冊(cè)表單上添加條款和條件復(fù)選框add_action('woocommerce_register_form', 'add_terms_and_conditions_to_registration', 20);函數(shù) add_terms_and_conditions_to_registration() {如果 (wc_get_page_id('terms') > 0 &&is_account_page()) {?><p class="form-row terms wc-terms-and-conditions"><label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox"><輸入類型=復(fù)選框"class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox";名稱=條款"<?php 已檢查( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true );?>id=條款"/><span><?php printf( __( '我已經(jīng)閱讀并接受了 <a href="%s" target="_blank" class="woocommerce-terms-and-conditions-鏈接>條款&amp;條件</a>', 'woocommerce'), esc_url(wc_get_page_permalink('terms')));?></span><span class="required">*</span><輸入類型=隱藏"名稱=術(shù)語(yǔ)字段"值=1"/></p><?php}}//驗(yàn)證所需的條款和條件復(fù)選框add_action('woocommerce_register_post', 'terms_and_conditions_validation', 20, 3);函數(shù)terms_and_conditions_validation( $username, $email, $validation_errors ) {if ( !isset( $_POST['terms'] ) )$validation_errors->add( 'terms_error', __( '條款和條件未檢查!', 'woocommerce' ) );返回 $validation_errors;}

    代碼位于活動(dòng)子主題(或活動(dòng)主題)的 function.php 文件中.經(jīng)測(cè)試有效.

    未勾選復(fù)選框時(shí),將顯示錯(cuò)誤消息.

    <塊引用>

    此復(fù)選框只是一個(gè)驗(yàn)證步驟(它不會(huì)保存在數(shù)據(jù)庫(kù)中,因?yàn)槲覀儾粫?huì)在任何地方使用該信息).


    補(bǔ)充:

    僅在注冊(cè)頁(yè)面允許條款和條件,請(qǐng)使用以下方法之一:

    add_filter('woocommerce_checkout_show_terms', '__return_false');

    add_filter('woocommerce_get_terms_and_conditions_checkbox_text', '__return_false');

    代碼位于活動(dòng)子主題(或活動(dòng)主題)的 function.php 文件中.已在 WC 3.5+ 上測(cè)試并有效.

    In woocommerce registration form, there's no "terms and conditions" before sign up button.

    Is there a way to make it appears in the form?

    Here is the link of my theme layout.

    解決方案

    Updated on july 2018 - Added compatibility for Woocommerce version 3.4+

    If not done yet, first you need enable terms and conditions on checkout page:

    1. To create a new page in Wordpress for your terms and conditions
    2. To enable that page in Woocommerce > Settings > Checkout > Checkout pages (section):
    3. Then save… you are done.


    The code to get the term and conditions check box on registration form:

    // Add term and conditions check box on registration form
    add_action( 'woocommerce_register_form', 'add_terms_and_conditions_to_registration', 20 );
    function add_terms_and_conditions_to_registration() {
    
        if ( wc_get_page_id( 'terms' ) > 0 && is_account_page() ) {
            ?>
            <p class="form-row terms wc-terms-and-conditions">
                <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
                    <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" /> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank" class="woocommerce-terms-and-conditions-link">terms &amp; conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></span> <span class="required">*</span>
                </label>
                <input type="hidden" name="terms-field" value="1" />
            </p>
        <?php
        }
    }
    
    // Validate required term and conditions check box
    add_action( 'woocommerce_register_post', 'terms_and_conditions_validation', 20, 3 );
    function terms_and_conditions_validation( $username, $email, $validation_errors ) {
        if ( ! isset( $_POST['terms'] ) )
            $validation_errors->add( 'terms_error', __( 'Terms and condition are not checked!', 'woocommerce' ) );
    
        return $validation_errors;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.

    When checkbox is not ticked, an error message is displayed.

    This checkbox is only a validation step (It is not saved in database, as we don't use that information anywhere).


    Addition:

    To allow terms and conditions only in Registration page use one of the following:

    add_filter( 'woocommerce_checkout_show_terms', '__return_false' );
    

    Or

    add_filter( 'woocommerce_get_terms_and_conditions_checkbox_text', '__return_false' );
    

    Code goes in function.php file of your active child theme (or active theme). Tested on WC 3.5+ and works.

    這篇關(guān)于在 Woocommerce 注冊(cè)表中添加條款和條件復(fù)選框的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

    相關(guān)文檔推薦

    Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
    Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
    Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗(yàn)證問(wèn)題中添加自定義注冊(cè)字段)
    Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡(jiǎn)單產(chǎn)品中添加一個(gè)將更改價(jià)格的選擇字段)
    Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
    Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
    主站蜘蛛池模板: 直读光谱仪,光谱分析仪,手持式光谱仪,碳硫分析仪,创想仪器官网 | 西门子伺服电机维修,西门子电源模块维修,西门子驱动模块维修-上海渠利 | 知网论文检测系统入口_论文查重免费查重_中国知网论文查询_学术不端检测系统 | PCB厂|线路板厂|深圳线路板厂|软硬结合板厂|电路板生产厂家|线路板|深圳电路板厂家|铝基板厂家|深联电路-专业生产PCB研发制造 | 沧州友城管业有限公司-内外涂塑钢管-大口径螺旋钢管-涂塑螺旋管-保温钢管生产厂家 | 开云(中国)Kaiyun·官方网站 - 登录入口 | 法兰连接型电磁流量计-蒸汽孔板节流装置流量计-北京凯安达仪器仪表有限公司 | TTCMS自助建站_网站建设_自助建站_免费网站_免费建站_天天向上旗下品牌 | 定量包装秤,吨袋包装称,伸缩溜管,全自动包装秤,码垛机器人,无锡市邦尧机械工程有限公司 | 长沙印刷厂-包装印刷-画册印刷厂家-湖南省日大彩色印务有限公司 青州搬家公司电话_青州搬家公司哪家好「鸿喜」青州搬家 | DDoS安全防护官网-领先的DDoS安全防护服务商 | 气体热式流量计-定量控制流量计(空气流量计厂家)-湖北南控仪表科技有限公司 | 深圳彩钢板_彩钢瓦_岩棉板_夹芯板_防火复合彩钢板_长鑫 | 恒温恒湿试验箱厂家-高低温试验箱维修价格_东莞环仪仪器_东莞环仪仪器 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 膏方加工_丸剂贴牌_膏滋代加工_湖北康瑞生物科技有限公司 | 水平筛厂家-三轴椭圆水平振动筛-泥沙震动筛设备_山东奥凯诺矿机 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 | 淬火设备-钎焊机-熔炼炉-中频炉-锻造炉-感应加热电源-退火机-热处理设备-优造节能 | 天津仓库出租网-天津电商仓库-天津云仓一件代发-【博程云仓】 | EPK超声波测厚仪,德国EPK测厚仪维修-上海树信仪器仪表有限公司 | 金联宇电缆|广东金联宇电缆厂家_广东金联宇电缆实业有限公司 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | SOUNDWELL 编码器|电位器|旋转编码器|可调电位器|编码开关厂家-广东升威电子制品有限公司 | 影视模板素材_原创专业影视实拍视频素材-8k像素素材网 | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 温控器生产厂家-提供温度开关/热保护器定制与批发-惠州市华恺威电子科技有限公司 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | 空气弹簧|橡胶气囊|橡胶空气弹簧-上海松夏减震器有限公司 | 无锡门窗-系统门窗-阳光房-封阳台-断桥铝门窗厂[窗致美] | 河北码上网络科技|邯郸小程序开发|邯郸微信开发|邯郸网站建设 | 微学堂-电动能源汽车评测_电动车性能分享网 | 断桥铝破碎机_发动机破碎机_杂铝破碎机厂家价格-皓星机械 | 西安中国国际旅行社(西安国旅) | 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 液氮罐(生物液氮罐)百科-无锡爱思科 | 苏州工作服定做-工作服定制-工作服厂家网站-尺品服饰科技(苏州)有限公司 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | 肉嫩度仪-凝胶测试仪-国产质构仪-气味分析仪-上海保圣实业发展有限公司|总部 | 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 | 清水-铝合金-建筑模板厂家-木模板价格-铝模板生产「五棵松」品牌 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 |