In order to create a pay per view site for training video's via WooCommerce, I am using the "purchase note field" to send an email with a hyperlink to a video-page upon completion of the order. This works ok, but if you go to the my accounts page customers can't go to 'My Accounts' and see all their links in one place as they can with 'Available Downloads'.
I would like to show two extra fields in the table of the my-account.php page, "product (item) name" and "purchase note". Currently there are 4 fields: "order", "shipping", "total" and "status" in the standard table.
As I am not using shipping options (just a virtual product), I would like to change this field to product (item) name. As mentioned I would like to add the field "purchase notes" (this will show my video url upon completion of the payment) Important is that this purchase note field can only be displayed once the item is completed. It does this already in the order-details.php page, but I would like to have this in the table in my-accounts.php page
The current code for this purchase note field in the order-details.php field is:
// 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 anyone show me what I need to change in my-account.php to accomplish these 2 extra fields in this page?
Click on the Customizer and you will be redirected to the live editing panel of the plugin where you will see your WooCommerce My Account Page on the right and the customization tools on the left. The Navigation Option lets you customize the Account Page menu.
my-account.php
is calling to several other templates, you need my-orders.php
. Place a copy in your theme folder to make it update proof.
I am assuming you are using 1.6.6 here, because the my account page has changed from 2.0 and doesn't include the shipping address any longer.
remove line 50, which shows the shipping address. You can edit/replace this and call 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'm assuming you only have one product per order?):
foreach($order->get_items() as $item) {
$product_name = $item['name'];
}
then simply call $product_name
in an extra column (copy/paste/edit code another column)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With