简体   繁体   English

Woocommerce-在购物车更新中保留条款和条件

[英]Woocommerce - Keep terms and conditions checked on cart update

Good morning everyone. 大家,早安。 I have a kind of strange request, in my woocommerce website I gave the option to take orders manually through phone calls, so there is a person that answer the calls and create orders for various customers. 我有一个奇怪的要求,在我的woocommerce网站上,我可以选择通过电话手动接订单,所以有人可以接听电话并为各种客户创建订单。

This person use a custom made page to register orders, with the possibility to select an existing user or to create a new one, to add items to cart and to fill the shipping/billing address. 此人使用定制的页面注册订单,可以选择现有用户或创建新用户,以将商品添加到购物车并填写送货/开票地址。 In this page there is also the order review section with the checkbox of terms and conditions that everytime must be checked to complete the order. 在此页面中,还有一个“订单检查”部分,其中包含条款和条件复选框,每次都必须选中此复选框以完成订单。

Since this is waste of time in this case I'm looking for a way to keep this checkbox always checked. 由于在这种情况下这是浪费时间,因此我正在寻找一种始终选中此复选框的方法。

Currently I'm using this code in my functions.php to show the terms and conditions as checked 目前,我在我的functions.php中使用此代码来显示已检查的条款和条件

function check_terms() {
if(is_page('custom-page')) {
    return true;
}

add_filter( 'woocommerce_terms_is_checked', 'check_terms', 10 );
add_filter( 'woocommerce_terms_is_checked_default', 'check_terms', 10 );

This works until I add or remove a product in the cart, after that the checkbox is resetted to empty and I go back to the starting point. 这一直有效,直到我在购物车中添加或删除产品为止,之后复选框被重置为空,然后我回到起点。 So I'm here to ask if any of you know a trick to keep this checkbox checked. 因此,我在这里问大家是否知道使此复选框保持选中状态的技巧。 I've already tried JS but without success since it's not fired after the update. 我已经尝试过JS,但是没有成功,因为它在更新后没有触发。

Thank you in advance and sorry for my english. 在此先感谢您,对不起我的英语。

Have a nice day. 祝你今天愉快。

function patricks_wc_terms( $terms_is_checked ) {
    return true;
}
add_filter( 'woocommerce_terms_is_checked', 'patricks_wc_terms', 10 );
add_filter( 'woocommerce_terms_is_checked_default', 'patricks_wc_terms', 10 );

Put this in your function.php file and try if any error then only replace function name 将其放在您的function.php文件中,然后尝试是否出现任何错误,然后仅替换函数名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM