-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4.latest
-- PHP version -- : 8.1
Hello,
I thought I was finished...
I have made a plugin that adds customer-specific information to the pdf of an E-book, and then makes it available for download. I am using onBeforeDownloadFile.
It works perfect for 1 pdf....but I have hit a small problem if the customer orders multiple downloadable products.
When hikashop executes onBeforeDownloadFile(&$filename, &$do, &$file, $options)
how can I obtain the information which download button was clicked?
Suppose that the customer has purchased 10 downloadable products, and is now in the download page. There are 10 buttons to click on for download. Click on button 1, and my plugin adjusts all 10 pdf files.....but unfortunately always shows the first one.
I can get the order ID from:
$order_id = $file->order_id;
I can get the entire order and user information from:
$app = JFactory::getApplication();
$orderClass = hikashop_get('class.order');
$FullOrder = $orderClass->loadFullOrder($order_id, true, false);
From that I can get for example the invoice number:
$InvNum = $FullOrder->order_invoice_number;
But how do I know which title (product ID) the customer wants to download?
Something like this will only iterate through all products.
foreach($FullOrder->products as $product) {
$ProductID = $product->order_product_code;
//adjust filename
}
I need to know which download product the customer just clicked on. So that I only have to adjust that specific pdf, and only show that specific pdf.
I guess the answer must be somewhere in your downloads.php.
Kind regards,
Alain