Post by satankoh666 » Wed Mar 20, 2019 2:13 pm

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.

Newbie

Posts

Joined
Wed Mar 20, 2019 10:02 am

Post by cyclops12 » Thu Mar 21, 2019 3:42 am

What about something like This

Active Member
Online

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by satankoh666 » Thu Mar 21, 2019 9:55 am

I see, thanks for your recommendation.

Newbie

Posts

Joined
Wed Mar 20, 2019 10:02 am

Post by cyclops12 » Fri Mar 22, 2019 4:04 am

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.

Active Member
Online

Posts

Joined
Sun Sep 27, 2015 1:10 am
Who is online

Users browsing this forum: No registered users and 1 guest