我试着hide 当我在woocommerce安装的结账页面上时,“货到付款”-支付网关[cop]。当我回显代码时,它会执行两次。一次正确,另一次截断url的结尾:
功能。php
// Disable gateway on checkout page
function payment_gateway_disable_cash_on_delivery_on_checkout( $available_gateways ) {
global $woocommerce;
global $wp;
// Helper
echo(" || get_page_link: ");
echo(get_page_link());
echo(" || wp->request: ");
echo(home_url( $wp->request));
echo(" || get_checkout_url: ");
echo($woocommerce->cart->get_checkout_url());
echo(" || end. ");
if ( isset( $available_gateways[\'cop\'] ) && (get_page_link() == $woocommerce->cart->get_checkout_url())) {
unset( $available_gateways[\'cop\'] );
}
return $available_gateways;
}
add_filter( \'woocommerce_available_payment_gateways\', \'payment_gateway_disable_cash_on_delivery_on_checkout\' );
签出页面上的输出
|| get_page_link: https://mypage.com/en/checkout/
|| wp->request: https://mypage.com/en/checkout/
|| get_checkout_url: https://mypage.com/en/checkout/ || end.
|| get_page_link: https://mypage.com/en/
|| wp->request: https://mypage.com/en/
|| get_checkout_url: https://mypage.com/en/checkout/ || end.
为什么会发生这种情况,或者如何解决?
以下是屏幕截图: