【问题标题】:WooCommerce PayPal Pro jquery.payment checkout form improvementsWooCommerce PayPal Pro jquery.payment 结帐表单改进
【发布时间】:2017-10-29 16:55:34
【问题描述】:

连接WC_Gateway_PayPal_Pro checkout 信用卡表单以在自定义主题上实现 jquery.payment 功能的正确方法是什么?

env 是最新的,使用:

  • WooCommerce v3.0.7
  • WooCommerce PayPal Pro(经典版和 PayFlow 版)网关 v4.4.6

jquery.payment 附带WooCommerce 并根据this article(...可能已过时)启用它是恢复到默认WC credit_card_form 的问题。

现在,我设法在“functions.php”中使用以下内容显示带有工作 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

根据文章,我认为我缺少的是“修改您的表单处理程序......以确保网关正在寻找正确的发布数据”,但是如何?找不到有关以下操作的任何相关文档,因此非常感谢您的指点:

woocommerce_credit_card_form_args
woocommerce_credit_card_form_fields
woocommerce_credit_card_form_start
woocommerce_credit_card_form_end

【问题讨论】:

    标签: paypal woocommerce hook-woocommerce


    【解决方案1】:

    最简单的方法是加入 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 );
    

    【讨论】:

      猜你喜欢
      • 2013-11-14
      • 2018-01-08
      • 2017-07-30
      • 2018-11-14
      • 2013-02-25
      • 2014-12-12
      • 2014-08-17
      • 2020-08-02
      • 2015-07-01
      相关资源
      最近更新 更多