【发布时间】:2018-09-04 19:16:16
【问题描述】:
您好,我一直在尝试向我的 Woocommerce 结帐页面添加一个额外的条件复选框,与条款和条件相同,但包含有关新 GDPR(数据保护)的信息和指向我的隐私政策的链接。他们必须先勾选复选框才能结帐。
我一直在使用从这里找到的各种 sn-ps 代码,并设法添加了一个条件复选框和一些文本,但无法添加指向隐私政策的链接。我必须将其添加到结帐框下方。理想情况下,我希望将链接放在复选框旁边,就像它出现在条款和条件一中一样。
如果能在结帐框中获取隐私页面链接,我们将不胜感激。
条件复选框隐私政策链接截图:
这是我目前所拥有的:
//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 href="http://127.0.0.1/protest/privacy-policy/" target="_blank">Privacy Policy</a><br/></h3>
</div>';
}
【问题讨论】:
标签: php wordpress checkbox woocommerce checkout