Hmm... I have similar working code for that in another homepage, but fail to get it to show up proper anywhere in Opencart even after changin to the correct tables to look in MySQL...
\n
\n
Total products:
".dbcount("(product_id)", "product")."
\n\n\n";
?>
Excuse the extra code, but THIS should work (but does not... grrr), can any PHP expert look into this maybes?
\n
\n
Total products:
".dbcount("(product_id)", "product")."
\n\n\n";
?>
Excuse the extra code, but THIS should work (but does not... grrr), can any PHP expert look into this maybes?

It depends on where the product info on the home page is coming from.
If it from the default installation "Latest Products" then the source is catalog\controller\home.php
** note also that the sorting bug fix is included in the sql statement. **
add another element to the $product_data array as follows
the array variable is already added to the template so where ever you put the following
in catalog\template\default\content\home.tpl then the quantity will appear.
It will be a similar (but not identical) process of review of controller and template followed by minor change wherever you want this.
If it from the default installation "Latest Products" then the source is catalog\controller\home.php
** note also that the sorting bug fix is included in the sql statement. **
Code: Select all
$results = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' order by p.date_added desc limit 6");
foreach ($results as $result) {
$product_data[] = array(
'name' => $result['name'],
'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id']))
);
}
Code: Select all
foreach ($results as $result) {
$product_data[] = array(
'name' => $result['name'],
'quantity' = $result['quantity'],
'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id']))
);
}
Code: Select all
<?php echo $product['quantity']; ?>
It will be a similar (but not identical) process of review of controller and template followed by minor change wherever you want this.
My code is like Frankensteins monster... I cannot post stuff that don't work as an "example". The hack I did for the address box at least works... 
Now I am inserting lots of items in Opencart, hopefully I'll get to 500, and after scanning/photos it should be 1000 items... Opencart is great!
Hope Opencart will get an internal category list tree - them "addons" bug a bit
but, at least they get the job done...

Now I am inserting lots of items in Opencart, hopefully I'll get to 500, and after scanning/photos it should be 1000 items... Opencart is great!
Hope Opencart will get an internal category list tree - them "addons" bug a bit

Step-bystep, how should the code look like, and what file should one edit to "paste" it in to get (look at image latest.jpg) something like this:
LATEST 6 PRODUCTS (307 ITEMS)
This is just a bad example, but the general idea here is to append to the line LATEST PRODUCTS a database (MySQL search) that show ALL the items one have in the store as a number...
Next logical step is to also show the net gross value, as an example:
LATEST 6 PRODUCTS (307 ITEMS WORTH $340)
LOL, I mean, there is a registered stat in the database thats just name the "figure" near each item, so all that is needed to get this is a DB query and then some sort of magic that "counts it together"... its just I am no good on it
Anyone good on stuff like this? Feel free to post code, I'll become very happy then...
LATEST 6 PRODUCTS (307 ITEMS)
This is just a bad example, but the general idea here is to append to the line LATEST PRODUCTS a database (MySQL search) that show ALL the items one have in the store as a number...
Next logical step is to also show the net gross value, as an example:
LATEST 6 PRODUCTS (307 ITEMS WORTH $340)
LOL, I mean, there is a registered stat in the database thats just name the "figure" near each item, so all that is needed to get this is a DB query and then some sort of magic that "counts it together"... its just I am no good on it

Anyone good on stuff like this? Feel free to post code, I'll become very happy then...

While I am writing the information I just remember a tiny detail that might be doable...
Question 1:
Let say I want to show the "total number" of items in the basic text:
Welcome Guest! Would you like to log yourself in? Or would you prefer to create an account?
Congratulations! You have successfully installed OpenCart.
Please begin to configure your installation in the administration.
Good Luck!
Like this:
Welcome Guest! We have XXX products!
Would you like to log yourself in? Or would you prefer to create an account?
Congratulations! You have successfully installed OpenCart.
Please begin to configure your installation in the administration.
Good Luck!
How do one insert the "code" there?
Question 2
Is there any way to also calculate the collected value of the items from the database products/price field and somehow add them up so one get a "total" sum... Would be very neat to show customers the toral aprox. value of all the stores items
We have a total of XXX items worth XXX <--- and this should be in a normal text inserted somewhere on the starting page... mmm! Sooo sweet! Is this doable...?
The very best regards from Sweden
Question 1:
Let say I want to show the "total number" of items in the basic text:
Welcome Guest! Would you like to log yourself in? Or would you prefer to create an account?
Congratulations! You have successfully installed OpenCart.
Please begin to configure your installation in the administration.
Good Luck!
Like this:
Welcome Guest! We have XXX products!
Would you like to log yourself in? Or would you prefer to create an account?
Congratulations! You have successfully installed OpenCart.
Please begin to configure your installation in the administration.
Good Luck!
How do one insert the "code" there?
Question 2
Is there any way to also calculate the collected value of the items from the database products/price field and somehow add them up so one get a "total" sum... Would be very neat to show customers the toral aprox. value of all the stores items

We have a total of XXX items worth XXX <--- and this should be in a normal text inserted somewhere on the starting page... mmm! Sooo sweet! Is this doable...?
The very best regards from Sweden
Not used to things working directly... you ARE good!!!!!!!!!! 
Finally most things on my little Opencart work as intended....
The only thing that keeps me from adding all the sweet extra "hacks" for opencart that mess with MySQL is if Daniel comes out with an upgrade
If one then uses alot of "extra" fluff like that sweet decimal hack (Swedish kronor looks no-good in Opencart now as an example) then it would be IMPOSSIBLE to "upgrade"... sob...
Oh, still, your code was SUPER-DUPER!!! Feels nice to see an aprox. value of all products... A cool thing you added was that it show the currency selected too, so it was EASY to switch from US dollar to Swedish kronor and see the value.... AHHH!!!!
A good coder sure can do miracles! Thanks alot!

Finally most things on my little Opencart work as intended....
The only thing that keeps me from adding all the sweet extra "hacks" for opencart that mess with MySQL is if Daniel comes out with an upgrade

Oh, still, your code was SUPER-DUPER!!! Feels nice to see an aprox. value of all products... A cool thing you added was that it show the currency selected too, so it was EASY to switch from US dollar to Swedish kronor and see the value.... AHHH!!!!
A good coder sure can do miracles! Thanks alot!
Who is online
Users browsing this forum: No registered users and 5 guests