我正在尝试执行以下操作; 如果产品具有查询字符串?redirect-cart
我的工作地点是: Clear WooCommerce Cart with a Query String and Redirect和 custom add to cart redirection for a defined product category in WooCommerce
这就是我所拥有的:[更新]
add_filter( 'woocommerce_add_to_cart_redirect', 'add_to_cart_checkout_redirection', 99, 1 );
function add_to_cart_checkout_redirection( $url ) {
// If the URL contains redirect_cart
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if ( false !== strpos( $url, 'redirect-cart' ) ) {
// Clear add to cart notice (with the cart link).
wc_clear_notices();
$url = wc_get_checkout_url().'?hide-custom-fields';
}
return $url;
}
不起作用。