The following problem: I would like to have a PDF button output for any number of orders. For this PDF button, the order ID and the item ID should be given for each order so that the PDF can be generated.
In the following code section I can also see what I mean with a picture from the frontend:
foreach ( $order->get_items() as $item_id => $item ) {
$order = new WC_Order( $_POST['oid'] );
$cid = get_user_meta( get_current_user_id(), 'company', true );
$result = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . "center_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/>';
}
}
The order ID of the order is saved in the Order ID column. The product ID is stored in the Item ID column for each order