• Resolved hyp0xia

    (@hyp0xia)


    I need finer control over the purchase note text of a product when the “thank you” page is being displayed. For whatever reason, I am completely unable to output the purchase note in the thankyou.php template. I’ve tried the following and every variation of it I could find to no avail..

    <?php
    if ( $purchase_note = get_post_meta( $product->id, '_purchase_note', true ) ) {
    	echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) );
    }
    ?>

    Looking for any possible insights into how to display product purchase notes in templates.

    Thank you very much.

Viewing 1 replies (of 1 total)
  • Thread Starter hyp0xia

    (@hyp0xia)

    After a relentless search I was finally able to nail down the code to display your purchase notes. More specifically, on the thank you page. (thankyou.php template).

    <?php $items = $order -> get_items(); foreach ( $items as $item ) { $product = $order -> get_product_from_item( $item ); // copied from woocommerce/templates/emails/email-order-items.php $purchase_note = get_post_meta( $product -> id, '_purchase_note', true ); echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); } ?>

    credit

    Incredibly useful for making custom-style thank you pages and notices instead of using a plug-in or wrangling much code.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying the purchase note in thankyou.php’ is closed to new replies.