Post by madaha » Mon May 26, 2008 1:02 pm

anyone can help?

New member

Posts

Joined
Thu Sep 06, 2007 6:02 pm

Post by Telefax » Mon Jun 16, 2008 3:25 am

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?  ;)

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Luvz2drv » Mon Jun 16, 2008 4:49 am

to show anything on the template file you must set it there...

so depending on what or where your counting is the controler/module file you will want to put your count in

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by Telefax » Mon Jun 16, 2008 5:27 am

I agree...  ;D

Could you maybes post some example code?  :-*

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by bruce » Mon Jun 16, 2008 6:48 am

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. **

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']))
			);
		}
add another element to the $product_data array as follows

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']))
			);
		}

the array variable is already added to the template so where ever you put the following

Code: Select all

<?php echo $product['quantity']; ?>
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.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Telefax » Mon Jun 16, 2008 7:03 am

very neat, so if I as an example want to show total customers, how should it then look?  ;D  Just confirming if I got it right with SQL....  :P

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Luvz2drv » Mon Jun 16, 2008 11:11 am

then why not post your code instead of my using my crystal ball...  lol (that was a joke)

but post your code for review.

Global Moderator

Posts

Joined
Fri Mar 21, 2008 10:58 am

Post by Telefax » Tue Jun 17, 2008 1:53 am

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...  ;D

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...

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Telefax » Tue Jun 17, 2008 3:37 pm

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...  ;D

Attachments

???
latest.jpg

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Telefax » Thu Jun 19, 2008 6:39 pm

I tried to insert the code: beside Latest Products but then I get a BLANK opencart page :(

To get a total listing of products (all-in-all) what is the PHP code and where do I insert it (what file or files)...

Anyone?  ;D

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Telefax » Fri Jun 20, 2008 10:50 pm

Works like a charm!  ;D

You sure know how to play the code...

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Telefax » Fri Jun 20, 2008 11:26 pm

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  :D

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

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm

Post by Telefax » Sun Jun 22, 2008 2:55 am

Not used to things working directly... you ARE good!!!!!!!!!!  ;D
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  :P 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!

New member

Posts

Joined
Sun Apr 06, 2008 4:47 pm
Who is online

Users browsing this forum: No registered users and 5 guests