【问题标题】:Express Checkout Paypal Payment Gateway For Woocommerce have issues with PolylangExpress Checkout Paypal Payment Gateway For Woocommerce 存在 Polylang 问题
【发布时间】:2021-10-26 07:04:43
【问题描述】:

如果我们从 Polylang 插件 URL 修改中设置语言选择 URL,那么 PayPal 结帐按钮在网站上的购物车和结帐页面上不起作用。

请检查一下,如果您对此问题有任何解决方案,请告诉我们。

谢谢!

【问题讨论】:

  • 插件好像不支持polylang插件。

标签: php wordpress woocommerce paypal


【解决方案1】:
add_filter('woocommerce_api_request_url', 'wt_woocommerce_api_request_url', 10, 3);

function wt_woocommerce_api_request_url($api_request_url, $request, $ssl) {

    if ( is_null( $ssl ) ) {
        $scheme = parse_url( home_url(), PHP_URL_SCHEME );
    } elseif ( $ssl ) {
        $scheme = 'https';
    } else {
        $scheme = 'http';
    }

    $lang = 'en';
    if ( function_exists('pll_current_language') ) {
     $lang =  pll_current_language();
    } 

    if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) {
        $api_request_url = trailingslashit( home_url(  $lang .'/index.php/wc-api/' . $request, $scheme ) );
    } elseif ( get_option( 'permalink_structure' ) ) {
        $api_request_url = trailingslashit( home_url(  $lang .'/wc-api/' . $request, $scheme ) );
    } else {
        $api_request_url = add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) );
    }

    return esc_url_raw( $api_request_url );
}

【讨论】:

  • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2011-09-16
  • 2015-09-10
  • 1970-01-01
  • 2017-04-22
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 2016-03-15
  • 2018-12-13
相关资源
最近更新 更多