Jump to content

userphp10

New Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

userphp10's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If someone more knowledgeable could help, I would appreciate.
  2. I think with this code i'm still gonna be redirected to order-received page nevertheless because this is just an if check. By the way are you using GPT? I tried it but to no avail.
  3. Did not work - I'm redirected straight to order-received page
  4. With your changes, after purchase I'm being redirected to order-received page straight away, but I need to be redirected to upsell-1 page
  5. Alright redirection to upsell works now after purchase after editing this part from if (is_wc_endpoint_url('order-received')) to if (!is_wc_endpoint_url('order-received')) but when in upsell-1 page after submitting button new item is added but I keep getting redirected back to upsell-1 page I should be redirected to order-received, I echoed out the url it is correct, but redirection is wrong. add_action('woocommerce_thankyou', 'upsell_redirect'); function upsell_redirect($order_id) { if (!is_wc_endpoint_url('order-received')) { return; } WC()->session->set('original_order_id', $order_id); $upsell_page_url = home_url('/upsell-1'); wp_redirect($upsell_page_url); exit; } add_action('template_redirect', 'process_upsell'); function process_upsell() { if (is_page('upsell-1') && isset($_GET['woocommerce_checkout_place_order'])) { $original_order_id = WC()->session->get('original_order_id'); if ($original_order_id) { $original_order = wc_get_order($original_order_id); $original_order->add_product(wc_get_product('875')); $original_order->calculate_totals(); $original_order->save(); $order_received_url = $original_order->get_checkout_order_received_url(); wp_redirect($order_received_url); exit; } } }
  6. This code checks firstly if user enters order-received url so that they won't be redirected to upsell-1 page all the time. But the problem is that after purchase i'm being redirected to order received page instead of upsell-1 page. Maybe validation must be written in different way (if (is_wc_endpoint_url('order-received'))) add_action('woocommerce_thankyou', 'upsell_redirect'); function upsell_redirect($order_id) { if (is_wc_endpoint_url('order-received')) { return; } WC()->session->set('original_order_id', $order_id); $upsell_page_url = home_url('/upsell-1'); wp_redirect($upsell_page_url); exit; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.