- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Stock quantity 0
Hi,
I have products that once they reach a quantity of 0 the still should be possible to be ordered on the frontend but the customer should be notified with a message next to the product with something like "1 to 3 delivery days". Or an image which show this.
The problem now is. My products that have a quantity of 0 are avaiable in the frontend and allowed to order, but the image won't change to "1 to 3 delivery days". They are shown as a normal in stock product.
So to make this more clear.
Situation prefered:
- Products with quantity more the 0 should be allowed to order with an image shown that says "delivery next day"
- Product with quantity 0 or lower should be allowed to order with an image shown "that says "delivery 1 to 3 working days".
Situation now:
- Products with quantity more the 0 are allowed to order with an image shown that says "delivery next day".
- Product with quantity 0 or lower are showing the same message as a product that is higher then quantity 0.
I hope it's clear what I'm trying to say
Hope someone can point me in the right direction how to solve this.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
You can check your product quantity and change the delivery status image accordingly.
Try this code.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface'); $stockQty = $StockState->getStockQty($product->getId(), $product->getStore()->getWebsiteId()); if ($stockQty > 0) { // deliver next day } else { // deliver in 1 to 3 days }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
Check the Swissup ProLables module.
It has stock label option - so you can set it to be visible when product stock quantity is 0.
You can apply an text or image to label.
Meet 70+ extensions and templates for M1 & M2 in one place
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
Where should I put this code?
And where the “// deliver next day” content comes in the code, how would I acces the delivery image and change this by code?
Thanks so far
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
I just gave an example with "// deliver next day".
Try to find out where your delivery image status is coming from.
Then put my if and else condition there.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
I'm still not sure where to add the suggested code. Have tried by activating template path hints for developers on front-end, but still no clue on where to add this.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
Anyone?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
No echo ...........................
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Stock quantity 0
Where do you exactly want to show the text?
Beside name in product detail page?
Beside SKU?
Beside Availability: InStock?
Let me know the exact section where you want to show the text so I can guide you that particular file where you can add this text.