• Resolved may

    (@mayeiei1)


    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)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @mayeiei1,

    You said “external print pdf button”, do you mean that the button is being created outside your store? Could you provide more details about what are you trying to achieve, so we can give you better advice?

    Thread Starter may

    (@mayeiei1)

    Yes, I have created a button is being created outside store and I want the accessKey to be generated automatically or without changing the request?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Thanks for providing more details, @mayeiei1:

    How are you getting the order details to build the button in this external context?

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hi @mayeiei1,

    Since we haven’t heard back from you in the last two weeks, we’re assuming you solved this issue, so I’ll go ahead and mark this ticket as Resolved.

    Feel free to reply to this topic is you still need help with this, or open a new topic if you have any other questions!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get URL for Guest Access’ is closed to new replies.