• Resolved yhazem

    (@yhazem)


    Hello,
    is there a way to change the placement of the product purchase note? in other words, I would like to place it at the top of the ‘order received’ page right below ‘Thank you, your order has been received.’.
    thank you for your help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Try this snippet:

    add_filter( 'woocommerce_thankyou_order_received_text', 'my_custom_thank_you_text', 10, 2 );
    function my_custom_thank_you_text( $default_text, $order ) {
      $default_text .= '</p><p>'.wp_kses_post( nl2br( wptexturize( $order->get_customer_note() ) ) );
      return $default_text;
    }

    If you want to remove the purchase note from the order details table, you’ll need to customise the order-details.php template. It would probably not be worthwhile to do that.

    Thread Starter yhazem

    (@yhazem)

    @lorro thank you for your prompt reply, but I wanted to add the product after purchase note not the customer purchase note. If you can help me do so that would be great.
    Thank you very much for your reply.

    I’m not sure what you mean by the purchase note if not the customer purchase note. Which product though? They may be many products in an order. And what information about the product – the titles and quantities of the product purchased are already in the Order Details section.

    For a redesigned thank you page, the thankyou.php template can be customised and the customised template put in your child theme. That’s probably a developer job. Your developer may want a graphic of the desired thank you page so its clear what you’re after.

    Thread Starter yhazem

    (@yhazem)

    This is the purchase note and it can be edited here on a woocommerce product. the thing is i want to change its position from the order details tab to the top of the woocommerce ‘order recieved’ page right bellow the ‘Thank you, your order has been received.’ text.

    Got it thank you. Its not a feature I’ve used.

    The thing is, the purchase note for which product? There may be one or several products on the order.

    You can use the ‘woocommerce_thankyou_order_received_text’ filter as above to link to your function to put additional content under the Thank you message.

    Your function needs to cycle through the items on the order, find the relevant product for each item, then find the purchase note for that product. The output would be in a table form, showing the product and the relevant purchase note. That’s a bit more code than would normally be expected in forum answers on this forum. PHP skills or a developer would be needed.

    It would be easier be leave the purchase notes where they are but to make them more noticeable with a style in Additional CSS:

    .product-purchase-note {
      font-weight: bold;
      font-size: 20px;
      color: #c00;
    }
    Thread Starter yhazem

    (@yhazem)

    Thank you @lorro ,
    I only allow users to purchase one product at a time on my website. Would that make it easier to display the purchase note, since it is only one.
    Thank you

    Yes that’s easier. Try:

    add_filter( 'woocommerce_thankyou_order_received_text', 'my_custom_thank_you_text', 10, 2 );
    function my_custom_thank_you_text( $text, $order ) {
      foreach( $order->get_items() as $item ) {
        $product = $item->get_product();
        $note = $product->get_purchase_note();
        break;
      }
      if( $note ) {
        $text .= '</p><p class="product-purchase-note">'.$note;
      }
      return $text;
    }
    Thread Starter yhazem

    (@yhazem)

    Thank you very much it worked perfectly 🙂

    Thread Starter yhazem

    (@yhazem)

    I have a final question,
    Is there a way to accept shortcodes too, because I have a shortcode placed in one of my purchase notes. It doesn’t appear on the newly positioned purchase notes although it appeared where it was before.
    Thank You very much.

    You can try

    if( $note ) {
      $note = do_shortcode( $note );
    

    but I can’t test it. Success may depend on what’s in the shortcode.

    Thread Starter yhazem

    (@yhazem)

    Thank you once again, it worked perfectly 🙂.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘purchase note placement’ is closed to new replies.