Method: Add Button in Footer of Thank You Page
Add this code to your functions.php file:
function custom_go_back_button_thank_you_footer() {
?>
<style>
.custom-thank-you-footer {
text-align: center;
margin-top: 30px;
padding: 20px 0;
}
.custom-thank-you-footer .button {
background-color: #0071a1; /* Customize button color */
color: #fff;
padding: 10px 20px;
text-decoration: none;
border-radius: 5px;
display: inline-block;
}
.custom-thank-you-footer .button:hover {
background-color: #005d85;
}
</style>
<div class="custom-thank-you-footer">
<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="button wc-backward">
← Go Back to Shop
</a>
</div>
<?php
}
add_action( 'woocommerce_after_thankyou', 'custom_go_back_button_thank_you_footer', 20 );
Explanation:
- The
woocommerce_after_thankyou
hook places the button at the bottom. - A
<div>
wrapper ensures proper styling & alignment. - The button links to the Shop page (
wc_get_page_permalink( 'shop' )
). - Custom CSS styles the button for a polished look.
Final Output:
A “Go Back to Shop” button appears at the bottom of the WooCommerce Thank You page, styled professionally.