Post by Mealz » Fri Oct 27, 2017 5:56 am

Hi :)
Is there any way of changing the colour of the little square behind the numbers or at which number they change colour at?
I have a new install of OC 2.3.0.2 and when out of stock, they're orange, low stock red and plenty of stock is green - I've attached a file to show you.

Firstly I want to change the out of stock to red and then adjust the numbers to suit our business a bit better.

Can anyone tell me where the code is I need to change and what to change it to?

Thank you so much!!

Attachments

stock-colour.jpg

stock-colour.jpg (13.36 KiB) Viewed 4196 times


New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by yodapt » Fri Oct 27, 2017 8:46 am

admin/view/stylesheet/bootstrap.css

Code: Select all

.label-default {
  background-color: #777; }
  .label-default[href]:hover, .label-default[href]:focus {
    background-color: #5e5e5e; }

.label-primary {
  background-color: #1e91cf; }
  .label-primary[href]:hover, .label-primary[href]:focus {
    background-color: #1872a2; }

.label-success {
  background-color: #8fbb6c; }
  .label-success[href]:hover, .label-success[href]:focus {
    background-color: #75a74d; }

.label-info {
  background-color: #5bc0de; }
  .label-info[href]:hover, .label-info[href]:focus {
    background-color: #31b0d5; }

.label-warning {
  background-color: #f38733; }
  .label-warning[href]:hover, .label-warning[href]:focus {
    background-color: #e66c0e; }

.label-danger {
  background-color: #f56b6b; }
  .label-danger[href]:hover, .label-danger[href]:focus {
    background-color: #f23b3b; }

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by Mealz » Fri Oct 27, 2017 7:58 pm

Thank you. That's what my file looks like so it seems like the issue must be with the numbering somehow.

How would I change so that zero is red
1-3 is orange
4+ is green?

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by yodapt » Fri Oct 27, 2017 10:57 pm

admin\view\template\catalog\product_list.tpl

Line 149 onwards

Code: Select all

<td class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-warning"><?php echo $product['quantity']; ?></span>
<?php } elseif ($product['quantity'] <= 5) { ?>
<span class="label label-danger"><?php echo $product['quantity']; ?></span>
<?php } else { ?>
<span class="label label-success"><?php echo $product['quantity']; ?></span>
<?php } ?></td>

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by Mealz » Sat Oct 28, 2017 6:42 am

My code looks like that too.

Should the 0 and 5 be swapped over? Is that why the out of stock is orange (warning?) and the low stock is red (danger?)
When out of stock should be red and low stock should be orange?

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by yodapt » Sat Oct 28, 2017 10:20 pm

It is working as it should, the colors are not swapped.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by straightlight » Sat Oct 28, 2017 11:03 pm

<td class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-warning"><?php echo $product['quantity']; ?></span>
<?php } elseif ($product['quantity'] <= 5) { ?>
<span class="label label-danger"><?php echo $product['quantity']; ?></span>
<?php } else { ?>
<span class="label label-success"><?php echo $product['quantity']; ?></span>
<?php } ?></td>
An idea to avoid further confusion based on the severity order of this functionality would be by replacing the above code from admin/view/template/catalog/product_list.tpl file,

with:

Code: Select all

<td class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-warning" data-toggle="tooltip" title="<?php echo $help_warning; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } elseif ($product['quantity'] <= 5) { ?>
<span class="label label-danger" data-toggle="tooltip" title="<?php echo $help_danger; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } else { ?>
<span class="label label-success" data-toggle="tooltip" title="<?php echo $help_success; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } ?></td>
In admin/controller/catalog/product.php file,

find:

Code: Select all

$this->load->model('design/layout');
add above:

Code: Select all

$data['help_warning'] = $this->language->get('help_warning');

$data['help_danger'] = $this->language->get('help_danger');

$data['help_success'] = $this->language->get('help_success');
Then, in admin/language/<your_language_code>/catalog/product.php file,

add at the bottom:

Code: Select all

$_['help_warning'] = 'Warning';
$_['help_danger'] = 'Danger';
$_['help_success'] = 'Success';
Then, refresh the product list page. Roll-over on those colors with your mouse. This should rectify the issue. In OC v3.x releases, this feature is already part of the core.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mealz » Sun Oct 29, 2017 7:13 am

I'm really confused!
Red for me would always mean out of stock - I don't understand why red is used for low stock.
Orange for me would mean low stock and yet low stock numbers are red.
I just want to change these colours over so that when the stock level is 0 the colour is red not orange. And when stock is low it is orange not red.

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by yodapt » Sun Oct 29, 2017 9:05 am

I see now what you mean, didnt notice the classes were wrong. Just swap label-warning with label-danger and it should be fine. If you want to change the stock quantity that affects colors, you can do so in that piece of code as well.

Code: Select all

<td class="text-right"><?php if ($product['quantity'] <= 0) { ?>
<span class="label label-danger" data-toggle="tooltip" title="<?php echo $help_warning; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } elseif ($product['quantity'] <= 3) { ?>
<span class="label label-warning" data-toggle="tooltip" title="<?php echo $help_danger; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } else { ?>
<span class="label label-success" data-toggle="tooltip" title="<?php echo $help_success; ?>"><?php echo $product['quantity']; ?></span></label>
<?php } ?></td>
Seems like v3 has the colors wrong as well.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by Mealz » Sun Oct 29, 2017 12:53 pm

I swapped them here - admin\view\template\catalog\product_list.tpl - and it made no difference.

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by kestas » Sun Oct 29, 2017 3:53 pm

Mealz wrote:
Sun Oct 29, 2017 12:53 pm
I swapped them here - admin\view\template\catalog\product_list.tpl - and it made no difference.
Hi,

did you clean after that all cash?

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by Mealz » Tue Oct 31, 2017 8:07 pm

kestas wrote:
Sun Oct 29, 2017 3:53 pm
Mealz wrote:
Sun Oct 29, 2017 12:53 pm
I swapped them here - admin\view\template\catalog\product_list.tpl - and it made no difference.
Hi,

did you clean after that all cash?
Yes, I cleared the cache and no difference.

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by straightlight » Tue Oct 31, 2017 8:49 pm

Mealz wrote:
Tue Oct 31, 2017 8:07 pm
kestas wrote:
Sun Oct 29, 2017 3:53 pm
Mealz wrote:
Sun Oct 29, 2017 12:53 pm
I swapped them here - admin\view\template\catalog\product_list.tpl - and it made no difference.
Hi,

did you clean after that all cash?
Yes, I cleared the cache and no difference.
Are you using any extensions that may include Journal2?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mealz » Wed Nov 01, 2017 5:04 am

straightlight wrote:
Tue Oct 31, 2017 8:49 pm
Mealz wrote:
Tue Oct 31, 2017 8:07 pm
kestas wrote:
Sun Oct 29, 2017 3:53 pm

Hi,

did you clean after that all cash?
Yes, I cleared the cache and no difference.
Are you using any extensions that may include Journal2?
Not that I'm aware of.

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by straightlight » Wed Nov 01, 2017 5:07 am

Can you provide the steps on the method that you cleared the cache?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mealz » Mon Nov 27, 2017 6:06 am

straightlight wrote:
Wed Nov 01, 2017 5:07 am
Can you provide the steps on the method that you cleared the cache?
I deleted all files in system>storage>cache except for index.html

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by straightlight » Mon Nov 27, 2017 6:48 am

In your admin/controller/marketplace/extension.php file,

find:

Code: Select all

$data['header'] = $this->load->controller('common/header');
add above:

Code: Select all

$this->load->model('setting/extension');
		
		echo "Extensions:<br />\n";
		
		echo "<pre />\n";
		print_r($data['categories']);
		echo "</pre>\n";
		
		$modules = $this->model_setting_extension->getInstalled('module');

		echo "Modules:<br />\n";
		
		echo "<pre />\n";
		print_r($modules);
		echo "</pre>\n";
		
		$totals = $this->model_setting_extension->getInstalled('total');

		echo "Totals:<br />\n";
		
		echo "<pre />\n";
		print_r($totals);
		echo "</pre>\n";
In your admin - > extensions - > extensions page, you will see a big list on top of the page. Copy it and paste it on your next reply between [ code ] and [ /code ] tags (without spaces for those tags)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mealz » Mon Nov 27, 2017 7:30 am

straightlight wrote:
Mon Nov 27, 2017 6:48 am
In your admin/controller/marketplace/extension.php file,

find:

Code: Select all

$data['header'] = $this->load->controller('common/header');
add above:

Code: Select all

$this->load->model('setting/extension');
		
		echo "Extensions:<br />\n";
		
		echo "<pre />\n";
		print_r($data['categories']);
		echo "</pre>\n";
		
		$modules = $this->model_setting_extension->getInstalled('module');

		echo "Modules:<br />\n";
		
		echo "<pre />\n";
		print_r($modules);
		echo "</pre>\n";
		
		$totals = $this->model_setting_extension->getInstalled('total');

		echo "Totals:<br />\n";
		
		echo "<pre />\n";
		print_r($totals);
		echo "</pre>\n";
In your admin - > extensions - > extensions page, you will see a big list on top of the page. Copy it and paste it on your next reply between [ code ] and [ /code ] tags (without spaces for those tags)
What will this do?

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm

Post by straightlight » Mon Nov 27, 2017 7:32 am

In your admin - > extensions - > extensions page, you will see a big list on top of the page. Copy it and paste it on your next reply between [ code ] and [ /code ] tags (without spaces for those tags)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mealz » Mon Nov 27, 2017 8:34 am

straightlight wrote:
Mon Nov 27, 2017 7:32 am
In your admin - > extensions - > extensions page, you will see a big list on top of the page. Copy it and paste it on your next reply between [ code ] and [ /code ] tags (without spaces for those tags)
Sorry, I don't understand.
A list of what?

New member

Posts

Joined
Fri Jul 26, 2013 4:58 pm
Who is online

Users browsing this forum: No registered users and 6 guests