For each $ item-> get_quantity () a PDF button should be issued with the order ID

  orders, php, woocommerce, wordpress

Due to the number of tickets I have ordered, I am currently trying to save a PDF button with a download link. This download link requires the OrderID for every order. The only problem is, I want several PDF download buttons to be issued if several tickets have been ordered.

My approach looks like this:


foreach ($item->get_quantity() as $value ) {
    $result = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . "coupon_codes WHERE order_id = '" . $order_id . "'", OBJECT );
    foreach ($result as $key => $value) {
        echo '<button><a style="color: #fff;" href="' . PLUGIN_URL . '../generate-pdf.php?oid=' . $order_id . '&item_id=' . $value->item_id . '" target="_blank">' .  pll_translate_string( 'PDF-Download', pll_current_language() ) . '</a></button><br/><br/>';
        if ( isset( $_POST[ 'new_employee_ticket_sending' ] ) && $_POST[ 'new_employee_ticket_sending' ] == 'on' ) {
            ticket_sending( $cid, $user_id );
        }
    }
}

The PDF button also needs the Item ID, among other things. Unfortunately, I’m running out of solutions. No PDF buttons are output in the front end. What can be the reason and is there a solution for it?

If so, thanks in advance.

Source: Ask PHP

LEAVE A COMMENT