Skip to content

Instantly share code, notes, and snippets.

@ragudesign
Last active April 26, 2019 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ragudesign/c2cc37c01bfb9a95186c83f5b9d6778d to your computer and use it in GitHub Desktop.
Save ragudesign/c2cc37c01bfb9a95186c83f5b9d6778d to your computer and use it in GitHub Desktop.
Adds a new action button on the WooCommerce order list to view the thank you page for each order.
<?php
// Add a new action button for the thank you page for each order
// WooCommerce version 3.3+
add_action( 'woocommerce_admin_order_actions_end', 'add_thankyou_page_action_button', 100, 1 );
function add_thankyou_page_action_button( $order ) {
// Add more order status here
if ( $order->has_status( array( 'processing', 'completed', 'partial-comp' ) ) ) {
$order_id = method_exists($order, 'get_id') ? $order->get_id() : $order->id;
$order_key = $order->get_order_key();
$url = esc_url(home_url().'/checkout/order-received/'.$order_id.'/?key='.$order_key);
$name = esc_attr( __('Thank You Page', 'woocommerce' ) );
$class = esc_attr( 'thankyou-page' );
// Custom action button (with a target='_blank' opening a new browser window)
printf( '<a class="button wc-action-button wc-action-button-%s %s" href="%s" title="%s" target="_blank">%s</a>', $class, $class, $url, $name, $name );
}
}
// The icon of your action button (CSS)
add_action( 'admin_head', 'add_thankyou_page_action_button_css' );
function add_thankyou_page_action_button_css() {
echo '<style>.wc-action-button-thankyou-page::after { font-family: woocommerce !important; content: "\e028" !important; }</style>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment