久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Woocommerce 中的歐洲 GDPR 附加結帳驗證復選框

European GDPR additional checkout validation checkbox in Woocommerce(Woocommerce 中的歐洲 GDPR 附加結帳驗證復選框)
本文介紹了Woocommerce 中的歐洲 GDPR 附加結帳驗證復選框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我一直在嘗試向我的 Woocommerce 結帳頁面添加一個額外的條件復選框,與條款和條件相同,但包含有關新 GDPR(數據保護)的信息以及指向我的隱私政策的鏈接.他們必須在結賬前勾選方框.

我一直在使用我在這里找到的各種代碼片段,并設法添加了一個條件復選框和一些文本,但無法添加隱私政策的鏈接.我必須將它添加到結帳框下方.理想情況下,我希望將鏈接放在復選框旁邊,就像條款和條件一上的那樣.

在結帳框中獲取隱私頁面鏈接的任何幫助將不勝感激.

條件復選框隱私政策鏈接截圖:

這是我目前所擁有的:

//這里是添加復選框的函數:函數 cw_custom_checkbox_fields( $checkout ) {echo '<div class="cw_custom_class"><h3>'.__('給出分隔標題:').'</h3>';woocommerce_form_field( 'custom_checkbox', array('類型' =>'復選框','標簽' =>__('協議政策.'),'必需' =>真的,), $checkout->get_value('custom_checkbox'));回聲'</div>';}add_action('woocommerce_checkout_after_terms_and_conditions', 'checkout_additional_checkboxes');函數 checkout_additional_checkboxes( ){$checkbox1_text = __( "我已閱讀并接受隱私政策并了解您如何根據 GDPR 管理我的數據", "woocommerce" );?><p class="form-row custom-checkboxes"><label class="woocommerce-form__label checkbox custom-one"><input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="custom_one" ><span><?php echo $checkbox1_text;?></span><span class="required">*</span></p><?php}add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');函數 my_custom_checkout_field_process() {//檢查是否設置,如果未設置則添加錯誤.如果(!$_POST['custom_one'])wc_add_notice( __( '您必須接受我已閱讀并接受隱私政策并了解您如何根據 GDPR 管理我的數據".' ), '錯誤' );}add_filter('comment_form_defaults','isa_comment_reform');add_action('woocommerce_after_checkout_form', 'wnd_checkout_message_bottom', 10);函數 wnd_checkout_message_bottom( ) {echo '<div class="wnd-checkout-message"><h3><a  target="_blank">隱私政策</a><br/></h3>

';}

解決方案

更新 (2018 年 5 月 - 代碼增強)

<塊引用>

woocommerce 3.4 新版本處理現在 GDPR

以下代碼將根據條款和條件,在結帳頁面中為新的強制性歐洲 GDPR 隱私政策添加一個額外的驗證復選框:

//在結帳頁面添加條款和政策復選框add_action('woocommerce_checkout_after_terms_and_conditions', 'add_terms_and_policy', 20);函數 add_terms_and_policy() {$domain = 'woocommerce';$gdpr_private_policy_link = sprintf('<a href="%s" target="_blank">%s</a>',home_url("/protest/privacy-policy/"),//GDPR隱私政策頁面的按鈕鏈接__( "隱私政策", $domain )//按鈕文本);woocommerce_form_field( 'gdpr_terms', 數組('類型' =>'復選框','類' =>數組('條款gdpr_terms'),'input_class' =>數組('woocommerce-form__input-checkbox'),'label_class' =>數組('woocommerce-form__label-for-checkbox'),'標簽' =>'<跨度>'.沖刺(__(我已閱讀并接受 %s 并了解您如何根據 GDPR 管理我的數據", $domain ),$gdpr_private_policy_link).'</span>','必需' =>真的,), '');}//驗證所需的 GDPR 私有策略復選框add_action('woocommerce_after_checkout_validation', 'terms_and_policy_validation', 20, 2);函數terms_and_policy_validation( $data, $errors ) {if ( !isset( $_POST['gdpr_terms'] ) ){$domain = 'woocommerce';$gdpr_text = sprintf(__(我已閱讀并接受 %s 并了解您如何根據 GDPR 管理我的數據", $domain ),__( "隱私政策", $domain ));$errors->add('gdpr_terms', sprintf( __( 'You must accept "%s".', $domain ), $gdpr_text ), 'error' );}}

代碼位于活動子主題(或活動主題)的 function.php 文件中.經過測試和工作.

如果不勾選,客戶將收到此錯誤信息,避免結賬:

Hi I have been trying to add an additional Conditional Check Box to my Woocommerce checkout page, the same as the Terms and Conditions one but with information about the new GDPR (data protection) and a link to my Privacy Policy. They must tick the box before they can check out.

I have been using various snippets of code put together from what I have found here and have managed to add a conditional check box and some text but have not been able to add a link to the Privacy Policy. I have to add it below the Checkout Box. Ideally I would like to have the link alongside the check box like it appears on the Terms and Conditions one.

Any help to get the Privacy page link within the checkout box would be appreciated.

Conditional Checkbox Privacy policy Link screenshot:

Here's what I have so far:

//Here is the function for adding the checkbox:
function cw_custom_checkbox_fields( $checkout ) {

    echo '<div class="cw_custom_class"><h3>'.__('Give Sepration Heading: ').'</h3>';

    woocommerce_form_field( 'custom_checkbox', array(
        'type'          => 'checkbox',
        'label'         => __('Agreegation Policy.'),
        'required'  => true,
    ), $checkout->get_value( 'custom_checkbox' ));

    echo '</div>';
}
add_action('woocommerce_checkout_after_terms_and_conditions', 'checkout_additional_checkboxes');
function checkout_additional_checkboxes( ){
    $checkbox1_text = __( "I have read and accept the Privacy Policy and understand how you manage my Data under GDPR", "woocommerce" );
       ?>
    <p class="form-row custom-checkboxes">
        <label class="woocommerce-form__label checkbox custom-one">
            <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="custom_one" > <span><?php echo  $checkbox1_text; ?></span> <span class="required">*</span>
        </label>
            </p>
    <?php
}

add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');

function my_custom_checkout_field_process() {
    // Check if set, if its not set add an error.
    if ( ! $_POST['custom_one'] )
        wc_add_notice( __( 'You must accept "I have read and accept the Privacy Policy and understand how you manage my Data under GDPR".' ), 'error' );
  }




add_filter('comment_form_defaults','isa_comment_reform');
add_action( 'woocommerce_after_checkout_form', 'wnd_checkout_message_bottom', 10 );

function wnd_checkout_message_bottom( ) {
 echo '<div class="wnd-checkout-message"><h3> <a  target="_blank">Privacy Policy</a><br/></h3>
</div>';
}

解決方案

Update (May 2018 - Code enhanced)

The new version of woocommerce 3.4 handle now GDPR

The following code, will add an additional validation checkbox for the new mandatory european GDPR Privacy Policy, under terms and conditions, in checkout page:

// Add terms and policy check box in checkout page
add_action( 'woocommerce_checkout_after_terms_and_conditions', 'add_terms_and_policy', 20 );
function add_terms_and_policy() {
    $domain = 'woocommerce';

    $gdpr_private_policy_link = sprintf( '<a href="%s" target="_blank">%s</a>',
        home_url("/protest/privacy-policy/"), // The button link to the GDPR privacy policy page
        __( "Privacy Policy", $domain )       // The button text
    );

    woocommerce_form_field( 'gdpr_terms', array(
        'type'          => 'checkbox',
        'class'         => array( 'terms gdpr_terms' ),
        'input_class'   => array('woocommerce-form__input-checkbox'),
        'label_class'   => array('woocommerce-form__label-for-checkbox'),
        'label'         => '<span>' . sprintf(
            __( "I have read and accept the %s and understand how you manage my Data under GDPR", $domain ),
            $gdpr_private_policy_link
        ) . '</span>',
        'required'      => true,
    ), '');
}

// Validate required GDPR private policy checkbox
add_action( 'woocommerce_after_checkout_validation', 'terms_and_policy_validation', 20, 2 );
function terms_and_policy_validation( $data, $errors ) {
    if ( ! isset( $_POST['gdpr_terms'] ) ){
        $domain = 'woocommerce';

        $gdpr_text = sprintf(
            __( "I have read and accept the %s and understand how you manage my Data under GDPR", $domain ),
            __( "Privacy Policy", $domain )
        );

        $errors->add( 'gdpr_terms', sprintf( __( 'You must accept "%s".', $domain ), $gdpr_text ), 'error' );
    }
}

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

If not checked, the customer will get this error message avoiding checkout:

這篇關于Woocommerce 中的歐洲 GDPR 附加結帳驗證復選框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 在线观看视频91 | 亚洲国产精品精华素 | 久久国产成人精品国产成人亚洲 | 久久久久久久久久影视 | 亚洲日日操 | 免费一区二区三区 | 一二区视频 | 一区二区成人 | 久久99精品国产 | 亚洲人人 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 天天久久 | 夜夜爽99久久国产综合精品女不卡 | 97caoporn国产免费人人 | 美女爽到呻吟久久久久 | 久久在线 | 国产在线一级片 | 成人av播放| 免费在线观看av | 日本黄色免费大片 | jav成人av免费播放 | 日本一区二区电影 | 日日草天天干 | 亚洲一级淫片 | 国产精品片aa在线观看 | 欧美在线a | 久久久99国产精品免费 | 人人艹人人爽 | 精品久久香蕉国产线看观看亚洲 | 国产精品九九九 | 福利一区视频 | 色毛片 | 久久国产成人精品国产成人亚洲 | 一区在线视频 | 一级片av| 欧美一卡二卡在线观看 | 免费亚洲网站 | 久久久久久久久久久久久9999 | 午夜一区二区三区在线观看 | 色综合天天天天做夜夜夜夜做 | 久久逼逼 |