sakiri Posted October 15, 2013 Share Posted October 15, 2013 Hi everybody, I'm about to add a column in the order-detail.tpl to show how many downloads for a virtual product are still available for a customer.But all I managed so far is adding the number of how often the product has already been downloaded, by using the value of {$product['download_nb']} How do I substract that value from the value stored in the field nb_downloadable of table ps_product_download? That is, how do I retrieve that value in order-detail.tpl? Thank you Link to comment Share on other sites More sharing options...
PascalVG Posted October 16, 2013 Share Posted October 16, 2013 If you have a full $product object available, maybe you can try this: $product->productDownload->nb_downloadable Didn't try, but give it a look. My 2 cents, pascal Link to comment Share on other sites More sharing options...
sakiri Posted October 16, 2013 Author Share Posted October 16, 2013 I thought I had... but this value isn't stored in the big ps_product table, but in ps_product_download and the nb_downloadable value (plus all other related data) gets only checked when the link for the downloadable item in the order history / order-detail.tpl is clicked If I'm not totally mixing up things, the value for nb_downloadable is provided for the first time through ProductDownload.php and checked in GetFileController.php (sends error message if download_nb is equal to nb_downloadable). So at the time when the order history is called, nb_downloadable is still "unknown"... So what I need is to bring forward the provision of this variable without throwing the following calls (ProductDownload.php, GetFileController.php) by double declarations or other funny beginners' stuff Any idea? Link to comment Share on other sites More sharing options...
sakiri Posted October 22, 2013 Author Share Posted October 22, 2013 Still need help with this topic ... I created a function (placed it in ProductDownload.php) which is a modification of the getFilenameFromIdProduct($id_product) function, only checking for the nb_downloadable value instead. But I still haven't figured out how to fill a new variable in the order-detail.tpl with it - I simply fail in finding the correct syntax. Need help please! Link to comment Share on other sites More sharing options...
sevkam Posted November 21, 2013 Share Posted November 21, 2013 Did you find the solution ? I want to do the exact same thing, and I'm facing the same issues. Link to comment Share on other sites More sharing options...
sakiri Posted November 21, 2013 Author Share Posted November 21, 2013 no, sorry, no solution yet Link to comment Share on other sites More sharing options...
bellini13 Posted November 22, 2013 Share Posted November 22, 2013 The number of times a download has occurred is stored in the "ps_order_detail.download_nb" column. Lets call this A The number of times a download may occur is stored in "ps_product_download.nb_downloadable" column. Lets call this B You would simply get these values and do the subtraction B - A. You need to add this logic to the OrderDetailController, initContent() function. Around line 168, you will see all the template variables being added to smarty (see below). So you would need to add your value to this smarty array, which will make it available to the template. So if you create a smarty variable called "nb_download_remaining", then in the template file you would access it using {$nb_download_remaining} $this->context->smarty->assign(array( 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int)($order->isReturnable()), 'currency' => new Currency($order->id_currency), 'order_state' => (int)($id_order_state), 'invoiceAllowed' => (int)(Configuration::get('PS_INVOICE')), 'invoice' => (OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection())), 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int)($order->id), false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC), /* DEPRECATED: customizedDatas @since 1.5 */ 'customizedDatas' => $customizedDatas /* DEPRECATED: customizedDatas @since 1.5 */ )); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now