我在Woocommerce中遇到一个问题,无法通过电话为客户付款。我们的某些客户不精通技术,喜欢以这种方式订购。我找到了下面的代码,当单击“客户付款页面”链接转到“结帐/订单付款”页面时,删除了登录要求,因此我们可以为客户输入付款明细。
有什么理由可能不安全吗?当然,客户的隐私和安全至关重要。
function allow_payment_without_login( $allcaps, $caps, $args ) {
// Check we are looking at the WooCommerce Pay For Order Page
if ( !isset( $caps[0] ) || $caps[0] != 'pay_for_order' )
return $allcaps;
// Check that a Key is provided
if ( !isset( $_GET['key'] ) )
return $allcaps;
// Find the Related Order
$order = wc_get_order( $args[2] );
if( !$order )
return $allcaps; # Invalid Order
// Get the Order Key from the WooCommerce Order
$order_key = $order->get_order_key();
// Get the Order Key from the URL Query String
$order_key_check = $_GET['key'];
// Set the Permission to TRUE if the Order Keys Match
$allcaps['pay_for_order'] = ( $order_key == $order_key_check );
return $allcaps;
}
add_filter( 'user_has_cap', 'allow_payment_without_login', 10, 3 );