Advertisement
majeedraza

WooCommerce - Show purchase note for first product on the thank-you page

Mar 16th, 2021
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. // WooCommerce - Show purchase note for first product on the thank-you page
  3. add_filter( 'woocommerce_thankyou_order_received_text', 'my_custom_thank_you_text', 10, 2 );
  4. function my_custom_thank_you_text( $text, $order ) {
  5.   foreach( $order->get_items() as $item ) {
  6.     $product = $item->get_product();
  7.     $note = $product->get_purchase_note();
  8.     break;
  9.   }
  10.   if( $note ) {
  11.     $text .= '</p><p class="product-purchase-note">'.$note;
  12.   }
  13.   return $text;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement