将WC_Gateway_PayPal_Pro
结帐信用卡表单挂钩以在自定义主题上实现jquery.payment功能的正确方法是什么?
env是最新的:
jquery.payment附带WooCommerce并根据this article(......可能已过期)启用此功能是恢复默认WC credit_card_form
。< / p>
现在,我设法在&#39; functions.php&#39;中使用以下内容显示带有工作jquery.payment输入的表单:
function filter_woocommerce_payment_gateway_supports( $var, $feature, $instance ) {
$feature = 'default_credit_card_form';
return $feature;
}
add_filter( 'woocommerce_payment_gateway_supports', 'filter_woocommerce_payment_gateway_supports', 10, 3 )
但这远远没有起作用(从未预料到那么容易),它只是不会验证。错误的范围从:
Payment error: There was a problem connecting to the payment gateway.
Payment error: Security header is not valid
Card expiration date is invalid
根据文章,我认为我缺少的是#34;修改表单处理程序...以确保网关正在寻找正确的帖子数据&#34;,但如何?无法找到有关以下操作的任何相关文档,因此需要非常感谢的指点:
woocommerce_credit_card_form_args
woocommerce_credit_card_form_fields
woocommerce_credit_card_form_start
woocommerce_credit_card_form_end
答案 0 :(得分:0)
最容易实现的是加入WC credit-card-form.js
脚本:
/*
* Enques credit-card-form.min.js to provide
* better Credit Card form validation
*/
function filter_woocommerce_enqueue_styles( $return_false ) {
if ( function_exists('is_checkout') ) {
if ( is_checkout() ) {
$WC_credit_card_form = plugins_url( 'woocommerce/assets/js/frontend/credit-card-form.min.js');
wp_enqueue_script('wc-credit-card-form', $WC_credit_card_form, ['jquery', 'jquery-payment'], null, true);
}
}
}
add_filter( 'woocommerce_enqueue_styles', 'filter_woocommerce_enqueue_styles', 10, 1 );