Get URL for Guest Access
-
Hi, I have created an external print pdf button and would like an accessKey to be able to auto-generate it to request a PDF file for printing.
The link looks like this:?https://website-name/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=invoice&order_ids=XXXXX&_wpnonce=XXXXXXXXXX
<?php echo "<td><a class='btn btn-primary printPdfButton' data-order-id='" . $details->id . "'></a></td>"; ?> <script> document.querySelectorAll('.printPdfButton').forEach(function(button) { button.addEventListener('click', function() { // Get the Order ID from the data-order-id attribute var orderId = this.getAttribute('data-order-id'); // Construct the URL with the dynamic Order ID // var accessKey = '7beccaaece'; // var url = 'https://localhost/test-ecom/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=packing-slip&order_ids=' + orderId + '&access_key=' + accessKey; var url = 'https://localhost/test-ecom/wp-admin/admin-ajax.php?action=generate_wpo_wcpdf&document_type=packing-slip&order_ids=' + orderId + '&access_key=7beccaaece'; // Open a new window and print the PDF var printWindow = window.open(url); printWindow.print(); }); }); </script>
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get URL for Guest Access’ is closed to new replies.