cart->is_empty() ) { WC()->cart->empty_cart(); } // Trigger woocommerce_thankyou so all standard hooks still fire. do_action( 'woocommerce_thankyou_' . $order->get_payment_method(), $order_id ); do_action( 'woocommerce_thankyou', $order_id ); $destination = get_option( 'aisp_otools_admin_redirect_destination', 'order' ); $hpos_enabled = false; if ( class_exists( '\Automattic\WooCommerce\Utilities\OrderUtil' ) ) { $hpos_enabled = \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); } switch ( $destination ) { case 'order': if ( $hpos_enabled ) { $url = admin_url( 'admin.php?page=wc-orders&action=edit&id=' . $order_id ); } else { $url = admin_url( 'post.php?post=' . $order_id . '&action=edit' ); } break; case 'order_list': if ( $hpos_enabled ) { $url = admin_url( 'admin.php?page=wc-orders' ); } else { $url = admin_url( 'edit.php?post_type=shop_order' ); } break; case 'dashboard': default: $url = admin_url(); break; } wp_safe_redirect( esc_url_raw( $url ) ); exit; } }