-
-
Save BeardedGinger/e58ab34416725fbc5ba02ea5262039de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_admin_order_data_after_order_details', 'ccef_order_switch_to', 99 ); | |
/** | |
* Add a switch to user link on the order details. | |
* | |
* @param object $order The WC Order that we're working with. | |
*/ | |
function ccef_order_switch_to( $order ) { | |
$user_switching = $GLOBALS['user_switching']; | |
if ( $user_switching ) { | |
$user = get_user_by( 'id', $order->get_user_id() ); | |
$switch_link = $user_switching::maybe_switch_url( $user ); | |
if ( $switch_link ) { | |
echo '<a href="' . esc_url( $switch_link ) . '">Switch To</a>'; | |
} | |
} | |
} |
Can you help me out with a simple question?
Do I add this to an exhisting page or do I create a new .php and save it in the plugin folder? Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to do the trick, it stops a fatal error if no user is already associated with the order.