Last active
April 26, 2019 12:29
-
-
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.
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 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