• Resolved magapascansky


    Hello! I am developing my own WooCommerce theme for my site and I’m having trouble with the thank you / order received page. Whenever I purchase something it redirects me to my homepage (that I understand is because I have no thank you page) with this url http://localhost:8888/dacre/finalizar-comprar/order-received/112/?key=wc_order_TmuIT5610SQvm

    I tried creating a thankyou.php under mytheme/woocommerce/checkout but it doesn’t work.

    Can you help me with these? I want to custom my thank you page including all the details from the purchase.

    Thank you in advance!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sometimes, redirection issues can be caused by permalink settings. Go to WordPress Admin > Settings > Permalinks and simply click “Save Changes” without making any changes. This action flushes the permalink structure and can resolve routing issues.

    If that doesn’t work, make sure that the thank you page php is structured correctly:

    defined( 'ABSPATH' ) || exit;
    global $wp;
    // Check if the order exists.
    if ( isset( $wp->query_vars['order-received'] ) ) {
        $order_id = absint( $wp->query_vars['order-received'] );
    } else {
        $order_id = 0;
    $order = wc_get_order( $order_id );
    if ( $order && $order->has_status( 'completed' ) ) {
        // Your customizations here. For example:
        echo '<p>Thank you. Your order has been received.</p>';
        // Display order details.
        echo '<ul>';
        echo '<li>Order number: ' . $order->get_order_number() . '</li>';
        echo '<li>Date: ' . wc_format_datetime( $order->get_date_created() ) . '</li>';
        echo '<li>Email: ' . $order->get_billing_email() . '</li>';
        echo '<li>Total: ' . $order->get_formatted_order_total() . '</li>';
        echo '<li>Payment method: ' . $order->get_payment_method_title() . '</li>';
        echo '</ul>';
        // Display additional information - e.g., customer details, products ordered.
        // This part is highly customizable depending on what details you want to show.
    } else {
        // If order not found or not completed.
        echo '<p>Order not found or has not been completed.</p>';
    Thread Starter magapascansky


    Hello and thanks for your quick response! I tried saving changes in permalink and also copying your code in my thankyou.php that is located under mytheme/woocommerce/checkout but neither worked 🙁

    Plugin Support anastas10s (woo-hc)


    👋 hey @magapascansky

    Thanks for reaching out to Woo Support!

    Hello! I am developing my own WooCommerce theme for my site and I’m having trouble with the thank you / order received page.

    From what I gather, you’d need a hand with template overriding via a theme.

    Luckily, there’s documentation on that, which can be found linked directly here, for your convenience.

    I hope this is helpful! Please let us know if you have any further questions or concerns.
    We will be happy to help you further.

    Thread Starter magapascansky


    Hello! That is what I tried but my theme isn’t even redirecting to the original template. It just goes to my index.php with the url http://localhost:8888/dacre/finalizar-comprar/order-received/119/?key=wc_order_FsNx6ZpbfAO4d.

    Thread Starter magapascansky


    I also tried with this code in my functions.php but it didn’t work either.

    function wc_custom_thank_you_page( $order_id ) {

    $order = wc_get_order( $order_id );

    wp_redirect( ‘http://localhost:8888/dacre/thank-you/&#8217; );


    add_action( ‘woocommerce_thankyou’, ‘wc_custom_thank_you_page’ );


    Thread Starter magapascansky


    Update: this code worked but I want to send the purchase id as a parameter.

    add_action( ‘template_redirect’, ‘woo_custom_redirect_after_purchase’ );

    function woo_custom_redirect_after_purchase() {

    global $wp;

    if ( is_checkout() && !empty( $wp->query_vars[‘order-received’] ) ) {

    wp_redirect(home_url() . “/thank-you”);




    Plugin Support Shameem (woo-hc)


    Hi @magapascansky,

    To send the purchase ID as a parameter, you need to modify the redirection URL in your function. You can access the order ID with $wp->query_vars['order-received'] and append it to the URL as a parameter.

    For reference, these particular forums are meant for general support with the core functionality of WooCommerce itself. For development and custom coding questions, it’s best to ask for insight related to those on either the WooCommerce Advanced Facebook group or the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question.

    I wish I could help more, but hopefully, this gets you going in the right direction to get some further insight/information.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.