I'm completely new to WordPress and I am trying to set up a simple store. It works fine, but I want my customers to be able to view the invoice right away from their orders. I downloaded the WooCommerce Print Invoices & Delivery Notes plugin, but it only allows me to print the invoice, not the customer. Therefore, I modified the WooCommerce /templates/myaccount/my-orders.php
file to include a button that generates the invoice:
/* USERCONTENT */
if ( $order->status == 'completed' ) {
$actions['invoice'] = array(
'url' => wp_nonce_url( '/wp-admin/admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $order->id , 'generate_print_content' ),
'name' => __( 'Invoice', 'woocommerce' )
);
}
/* ENDUSERCONTENT */
This works when I view my orders. I assigned a test order to myself:
Clicking the Invoice button opens the invoice generated by the WooCommerce Print Invoices & Delivery Notes Plugin, which is exactly what I want. But it does not work for my customers. They see a webpage with the message "You do not have sufficient permissions to access this page." instead.
My assumption is that it has to do with the fact that it is accessing /wp-admin/admin-ajax.php
. Is there another ~-ajax.php
that I can invoke the GET on and users will have access to?