1

Is there possibility of adding a new "stock status" which would be independent of the stock. It would say something like "On order >14days" or "On order <7days"

They'd be changed only manually.

1 Answer 1

0

create a product attribute called order_stock_status that will need to be set visible on front

and then on the product detail page, in the template where you want to display the custom stock message, you may use the code below or at least inspire yourself from it:

class ProductStockInfo extends \Magento\Catalog\Block\Product\AbstractProduct
{
    public function getProductStockStatus()
    {
        $product = $this->getProduct();

        if ($product->getOrderStockStatus()) {
            $stockMessage = $product->getOrderStockStatus();
        } else {
            if ($product->isAvailable()) {
                $stockMessage = 'In stock';
            } else {
                $stockMessage = 'Out of stock';
            }
        }

        return $stockMessage;
    }
}

this way, you can take over Magento stock status.

if the above works for you, the next thing is to hide the add to cart button from the addtocart.phtml template replacing <?php if ($_product->isSaleable()): ?> by <?php if (!$product->getOrderStockStatus() && $_product->isSaleable()): ?>

same will apply in products.phtml template

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.