【发布时间】:2021-10-26 07:04:43
【问题描述】:
如果我们从 Polylang 插件 URL 修改中设置语言选择 URL,那么 PayPal 结帐按钮在网站上的购物车和结帐页面上不起作用。
请检查一下,如果您对此问题有任何解决方案,请告诉我们。
谢谢!
【问题讨论】:
-
插件好像不支持polylang插件。
标签: php wordpress woocommerce paypal
如果我们从 Polylang 插件 URL 修改中设置语言选择 URL,那么 PayPal 结帐按钮在网站上的购物车和结帐页面上不起作用。
请检查一下,如果您对此问题有任何解决方案,请告诉我们。
谢谢!
【问题讨论】:
标签: php wordpress woocommerce paypal
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 );
}
【讨论】: