ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Show Price in website


#1

Hello Dears

In item page in website it shows item price only if it is in stock

but we need to show item price even if its not in stock

what should i do ?


#2

Any news.?


#3

@Mahmoud_Ghoneem Do you have the “Allow Negative Stock” setting checked in the “Stock>Stock Settings” settings?


#4

No. But why ?

What is the relationship between them ?


#5

Sorry for the delay. I was just curious. I do not know if there is a relationship from a code perspective. However, I have that checked, and I can see items that are not in stock on my front end.

Could you provide an example of the settings for an item that is exhibiting this behavior? Also, what version are you on?


#6

Have you figured this out?


#7

I don’t know if this will help, but this post includes a comment about unhiding items on the website - maybe the same approach will work for the price?


#8

i think our issue here in this file


#9

@Mahmoud_Ghoneem Sorry for the delay on this. If you’ve identified the solution, please disregard. The code above just changes the styling of the stock details attribute for the item, it doesn’t control the I think there is a bug or something because there seem to be a few things at play here. Looking at the code you referenced, I think the issue is actually up a bit in the code https://github.com/frappe/erpnext/blob/0692e5eb78564b4070880a234c61a0382bccf082/erpnext/templates/includes/product_page.js#L16-L20 This is where the logic starts to determine whether to show or hide the “add to cart.” functionality in the website. The logic from what I can tell goes something like the following:

If in the “Shopping Cart Settings” (found in the Website Section), the “Enable purchase of items via the website” is checked, then check to see if the following conditions are true and hide the item-cart, item-price, and item-stock (Effectively removing the ability to see price, stock, and the add item to cart button):

IF there is no price on the item OR IF the item is not in stock AND the “Shopping Cart Settings” setting “Allow items not in stock to be added to cart” is not checked, then hide these three elements.

I’m still working through understanding all the pieces on this one because it’s a bit of a pain. What seems to work is that if you have “Maintain Stock” unchecked in the actual item, it will show up. If I have it checked and no stock, and even with the “Allow Items not in stock to be added to cart” setting, the price, stock, and add item elements do not show up.

I think there might be a logic issue in this code and I will let you know when I find it. Anyway, hope that helps.