Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter(
- 'woocommerce_get_return_url',
- function ( $return_url, $order ) {
- if ( ! $order instanceof WC_Order ) {
- return $return_url;
- }
- if ( ! $order->has_status( array( 'processing', 'completed', 'on-hold' ) ) ) {
- return $return_url;
- }
- $redirect_url = home_url( '/account/edit-account/' );
- $target_slug = 'post_package';
- $match = false;
- foreach ( $order->get_items() as $item ) {
- $product = $item->get_product();
- if ( ! $product ) {
- continue;
- }
- if ( $product->get_type() === $target_slug ) {
- $match = true;
- break;
- }
- }
- return $match ? $redirect_url : $return_url;
- },
- 10,
- 2
- );
Advertisement
Add Comment
Please, Sign In to add comment