0

I'm trying to hook into the order received text and display a message based on the total order amount. This is what I currently have, but it's not working (thankyou-page is blank after title);

add_filter( 'woocommerce_thankyou_order_received_text', 'wpb_thankyou' );
function wpb_thankyou($order_id) {
     $order = wc_get_order( $order_id );
     $order_data = $order->get_data();
     $order_total = $order_data['cart_tax'];

    if ($order_total < "40") {
        $added_text = "Something";
    }
    else {
        $added_text = "Something else";
    }
    return $added_text ;
}
  • that WC filter gets the order object, not the ID so you can remove the $order = wc_get_order( $order_id ); line. If that doesn't fix it check your error logs, blank page after the thing you're editing suggests a PHP error. – mrben522 Jan 9 at 14:20
  • I tried removing it, but the same result. I also tried using add_action ('woocommerce_thankyou') instead of the filter and it works just fine. – Heinrich Held Jan 9 at 14:35
  • there was definitely something in your code that was causing a fatal error, it should be in your logs if you'd like to see what the root cause of the problem was – mrben522 Jan 9 at 14:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.