Page 1 of 1

How to add colored text to Product page stock availability

Posted: Wed Mar 20, 2019 2:13 pm
by satankoh666
Hi, I am new to this forum. No idea if this is the correct place to ask. I am not very good with PHP.

I am running 2.3.0.2, which has the show stock quantity on product page. I am trying to set the product page stock availability to show "In stock", in green text when the quantity is above 5. "Low Stock, 'quantity' Left", in orange, when the stock is below 5. "Out of stock", in red, when the stock is 0.

Somehow, I manage to get it to work as above 5, it shows "In Stock", below 5, it shows, "quantity", 0, it shows "Out of Stock". However, I am unable to add text to the quantity part, and also unable to change the text color.

What I had changed in catalog/controller/product/product.php is as follow:

From:
if ($product_info['quantity'] <= 0) {
$data['stock'] = $product_info['stock_status'];
} elseif ($this->config->get('config_stock_display')) {
$data['stock'] = $product_info['quantity'];
} else {
$data['stock'] = $this->language->get('text_instock');
}

To:
if ($product_info['quantity'] <= 5) {
$data['stock'] = $product_info['quantity'];
} elseif ($product_info['quantity'] <= 0) {
$data['stock'] = $product_info['stock_status'];
} else {
$data['stock'] = $this->language->get('text_instock');
}

The above changes was able to get the changes as I mention. But, I have trouble adding text and changing the color to it in HTML. Does anyone knows how to add text and also change the color?

Thanks in advanced.

Re: How to add colored text to Product page stock availability

Posted: Thu Mar 21, 2019 3:42 am
by cyclops12
What about something like This

Re: How to add colored text to Product page stock availability

Posted: Thu Mar 21, 2019 9:55 am
by satankoh666
I see, thanks for your recommendation.

Re: How to add colored text to Product page stock availability

Posted: Fri Mar 22, 2019 4:04 am
by cyclops12
No problem
Not my recommendation by the way, just searched for you
I have not used this so check it out to make sure it does what you require before purchasing.