When a buyer selects a downloadable product, it tries to manage the stock with messages like:
1 item in stock
Warning: Last items in stock!
Is there a way to disable stock management for these products, since its not relevant.
Thanks in avance,
If you think someone's answer helped, please give him/her a Positive Reputation vote by liking their post.
E-commerce hosting from Scotserve, fast, reliable and affordable.
The idea would be to disable stock management for downloadable products.
This is something that needs to be coded in you PS files.
<!-- number of item in stock -->quantity == 0)} style="display:none;"{/if}>
to
downloadable)) && ($display_qties != 1 || ($allow_oosp && $product->quantity == 0) )} style="display:none;"{/if}>
but that didn't seem to make any difference.
I'm new to PS code changes, suggestions on where to start?
There is a not a downloadable flag in the products, its a separate table.
Perhaps someone could provide links or tips on accessing the product objects from .tpl files?
public static function updateQuantity($product)
{
if (!is_array($product))
die (Tools::displayError());
/* if the product is downloadable, don't update quantity */
$result = Db::getInstance()->getRow('
SELECT *
FROM `'._DB_PREFIX_.'product_download'.'`
WHERE `id_product` = '.intval($product['id_product']));
if ($result)
return true;
...
The SQL might be more efficient if one just did "SELECT id_product_download" as opposed to "SELECT *"?
Or perhaps, use getIdFromIdProduct() from ProductDownload.php?
Maybe your code is also needed in checkQuantities() in Cart.php?
And product-sort.php?
As these are all places where PS_STOCK_MANAGEMENT is referenced.
But what about getting rid of "Availability: 1000 items in stock" on the item details page?
I think that needs to be handled on the display level, thus themes/prestashop/product.tpl?
There is a $display_qties in themes/prestashop/product.tpl, but I don't understand how it is set, can you help?
static public function getProductIsDownloadable($id_product)
{
$result = Db::getInstance()->getRow(' SELECT id_product_download FROM `'._DB_PREFIX_.'product_download'.'`
WHERE `id_product` = '.intval($id_product));
if ($result)
return true;
else
return false;
}
Then added to getProductProperties():
$row['is_downloadable'] = Product::getProductIsDownloadable($row['id_product']); /* SB */
And in "themes/product.tpl" reference is_downloadable:
quantity == 0 && !$product->available_later) || (!$product->available_now && $display_qties != 1) } style="display:none;"{/if}>
{l s='Availability:'}
"Availability:" is still shown on the stock page, so there must be a bug in my logic above, in how to get the downloadable flag onto the smarty template and control the display based on that.
Changes are needed to classes/Product.php product.php classes/Cart.php themes/default/product.tpl
I'll put it up on boran.com/presta where I keep my notes.
Is there some trick to get attachments to work correctly?
I've posted it here:
http://boran.com/sit...rum_10649_0.txt




Back to top









