I am using WooCommerce Print Invoice plugin to print invoices.
Now I am working on a Cordova app for my website and I need to be able to see invoices from wordpress.
Plugin has a function to hide or redirect page if you are not logged in.
public function print_document_action() {
// listen for ‘print’ action query string
if (isset($_GET[‘wc_pip_document’], $_GET[‘wc_pip_action’]) && ‘print’ === $_GET[‘wc_pip_action’]) {
// sanity check, if user is not logged in, prompt to log in
if (!is_user_logged_in()) {
wp_redirect(wc_get_page_permalink(‘myaccount’));
exit;
}
$nonce = isset($_REQUEST[‘_wpnonce’]) ? $_REQUEST[‘_wpnonce’] : ”;
// security admin/frontend checks
if (!$nonce || !wp_verify_nonce($nonce, ‘wc_pip_document’)) {
die(__(‘You are not allowed to view this page.’, ‘woocommerce-pip’));
}
Can this be overwritten from functions.php?
Tried to use entire function again, without those lines like this:
add_filter(‘print_document_action’, ‘showInvoices’, $priority = 9999, $args = 1);
function showInvoices() {
// same function without sanity check and security admin/frontend checks
}
Tried also to generate nounce with JSON API plugin and run page like this:
site.com/orders/?wc_pip_action=print&wc_pip_document=invoice&order_id=’+id+’&_wpnonce=’+nonce;
This also is not working.
Any ideas?
Read more here:: Override plugin function to show invoices even if not logged in