Show product name and purchase notes on the My Accounts page in WooCommerce

To create a pay-per-view site for training videos through WooCommerce, I use the Buy Note field to send an email with a hyperlink to the video page when the order is completed. This works fine, but if you go to my accounts page, customers will not be able to go to "My Accounts" and see all their links in one place, as they can, with "Available Downloads".

I would like to show two additional fields in the table table of my-account.php page, "product (item) name" and "note note". There are currently 4 fields in the standard table: order, dispatch, general, and status.

Since I do not use delivery parameters (virtual product only), I would like to change this field to the name of the product (product). As already mentioned, I would like to add the field "Purchase Notes" (this will show my video after the payment is completed) It is important that this field notes purchase can be displayed only after the completion of the item. He does this already on the order-details.php page, but I would like to have it in the table on the my-accounts.php page

The current code for this purchase field is in the order-details.php field:

// Show any purchase notes if ($order->status=='completed' || $order->status=='processing') : if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) : echo '<tr class="product-purchase-note"><td colspan="3">' . apply_filters('the_content', $purchase_note) . '</td></tr>'; endif; endif; endforeach; endif; do_action( 'woocommerce_order_items_table', $order ); ?> 

Can someone show me what I need to change in my-account.php in order to execute these 2 extra fields on this page?

+6
source share
1 answer

my-account.php calls several other templates, you need my-orders.php . Place a copy in the theme folder to update it.

I assume that you are using 1.6.6 here because my account page has changed from 2.0 and no longer includes a shipping address.

delete line 50 with the delivery address. You can edit / replace this and call up your purchase note with the following code:

 get_post_meta( $order->id, '_purchase_note', true) 

then you can get the product name (from your question, I assume that you only have one product per order?):

 foreach($order->get_items() as $item) { $product_name = $item['name']; } 

and then just call $product_name in an extra column (copy / paste / edit the code of another column)

+3
source

Source: https://habr.com/ru/post/927262/


All Articles