WooCommerce and ACF: How to Redirect Upon Add to Cart – Partially Working Example

Try with below code. i have tested and it is working fine for me.

add_filter( 'woocommerce_add_to_cart_redirect', 'acf_product_redirect' );
function acf_product_redirect() {
    #Get product ID
    if ( isset( $_REQUEST['add-to-cart'] ) ||  is_numeric( $_REQUEST['add-to-cart'] ) ) {
        $product_id = (int) apply_filters( 'woocommerce_add_to_cart_product_id', $_REQUEST['add-to-cart'] );
        # Check if redirect url set or not
        if (!empty(get_field('redirect_url', $product_id))) {
            $redirect_id = get_field('redirect_url', $product_id); 
            return get_permalink($redirect_id);
        }   
    }
}

Let me know if this works for you.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)