Post by SoCal » Wed Nov 18, 2009 6:08 am

Hey Gents,

( I have the quanity displaying now with the 1.34 version when you pull up the product details ... )

However, would there be a way to display the remaining quantity available on the home page .

Where the latest products are features.

Creating the sense of urgency ...

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by Daniel » Wed Nov 18, 2009 9:08 am

I think I already added this feature.

it should be under settings.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by SoCal » Wed Nov 18, 2009 9:23 am

I see the part that says

Display Stock
Display stock quantity on the product page. yes/no

but I don't see anywhere that would toggle "display stock quantity" on the home page ??

socal

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by SoCal » Thu Nov 19, 2009 4:34 am

Hey Q,

Got any tricks so I can display the in stock quantity available on the "home page"

(it shows up when viewing product details)

socal

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by SoCal » Tue Nov 24, 2009 7:16 am

Hello Q and Daniel,

Would either of you have any ideas regarding my objective of having the
Qty in Stock ... display on the home and category page.

My platform will offer "limited editions" and I'm trying to get my landing page (the home page)
to display the Quantity Avaible for each Limted Edition shown.

Thanks for your input guys.

socal

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by Xsecrets » Tue Nov 24, 2009 7:48 am

in catalog/controler/common/home.php change

Code: Select all

          	$this->data['products'][] = array(
            	'name'    => $result['name'],
		'model'   => $result['model'],
            	'rating'  => $rating,
		'stars'   => sprintf($this->language->get('text_stars'), $rating),
		'thumb'   => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
		'special' => $special,
		'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
          	);
to

Code: Select all

          	$this->data['products'][] = array(
            	'name'    => $result['name'],
		'model'   => $result['model'],
            	'rating'  => $rating,
		'stars'   => sprintf($this->language->get('text_stars'), $rating),
		'thumb'   => image_resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
		'quantity' => $result['quantity'],
		'special' => $special,
		'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
          	);
then in catalog/view/theme/{yourtheme}/template/common/home.tpl add

Code: Select all

<?php echo $products[$j]['quantity']; ?>
somewhere in the products loop wherever you want it. you may need to add appropriate breaks/styling etc.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by SoCal » Tue Nov 24, 2009 9:36 am

Thanks,

I'll give it a shot and report back.

socal

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by SoCal » Wed Nov 25, 2009 12:19 am

Xsecrets,

Thanks ! That worked great.

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by SoCal » Wed Nov 25, 2009 3:16 am

Hello Xsecrets ,

How could I do the same on the Category>product
page as well ?

Worked great on the home page.

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by Xsecrets » Wed Nov 25, 2009 4:17 am

in catalog/controller/product/category.php find around line 145

Code: Select all

'model'   => $result['model'],
make a new line after that and add

Code: Select all

'quantity' => $result['quantity'],
then in catalog/view/theme/{yourtheme}/template/product/category.tpl around line 54 (somewhere in the products loop) add

Code: Select all

<?php echo $products[$j]['quantity']; ?>
once again this has no styling whatsoever you can add that as you wish.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by SoCal » Wed Nov 25, 2009 5:54 am

That worked great.

Thanks alot.

socaL

New member

Posts

Joined
Fri Nov 07, 2008 3:23 pm

Post by socal2 » Tue Dec 01, 2009 4:30 am

Hey Xsecrets

An odd thing happens with the Quantity on the home page...

On the category page the amount is reduced with each sale.
On the product detail page the amount is also reduced with each sale.
Likewise, on the product insert / in administration ... the quantity is reduced with each sale.

However, on the home page the quantity doesn't reduce.

If I start a new session however , and come in new ... sometimes it looks like it's reducing it ... but then sometime not ... it's not consistent. (on the homepage that is... the other reduce quantity just great)

((just tried it again .... it's definately some type of session timing thing .... if I wait a while and come back in sometime later ... it seems to reduce the qty on the home page))

seems like it should reduce it after I checkout and hit the continue button at the very end bringing me back to the home page. ?

any ideas ??

http://www.imageart-studios.com/opencart13/

New member

Posts

Joined
Tue Dec 01, 2009 12:45 am

Post by socal2 » Wed Dec 02, 2009 11:09 pm

Xsecrets, you are correct. It was the cache setup on the home page.
Your solution worked great ! Thanks for your help.
socal



Re: remaining quantiy available
Sent: Tue Dec 01, 2009 4:53 pm
From: Xsecrets
To: socal2

ok I found it. it does cache the latestproducts query in the model file.

in catalog/model/catalog/product.php

please backup before you try this. The code should work, but I haven't tested it.

around line 156 you should see a function like

Code: Select all
public function getLatestProducts($limit) {
$product_data = $this->cache->get('product.latest.' . $this->language->getId() . '.' . $limit);

if (!$product_data) {
$query = $this->db->query("SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1' AND p.date_available <= NOW() AND pd.language_id = '" . (int)$this->language->getId() . "' AND ss.language_id = '" . (int)$this->language->getId() . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);

$product_data = $query->rows;

$this->cache->set('product.latest.' . $this->language->getId() . '.' . $limit, $product_data);
}

return $product_data;
}


change it to


Code: Select all
public function getLatestProducts($limit) {
$query = $this->db->query("SELECT *, pd.name AS name, p.image, m.name AS manufacturer, ss.name AS stock, (SELECT AVG(r.rating) FROM " . DB_PREFIX . "review r WHERE p.product_id = r.product_id GROUP BY r.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "manufacturer m ON (p.manufacturer_id = m.manufacturer_id) LEFT JOIN " . DB_PREFIX . "stock_status ss ON (p.stock_status_id = ss.stock_status_id) WHERE p.status = '1' AND p.date_available <= NOW() AND pd.language_id = '" . (int)$this->language->getId() . "' AND ss.language_id = '" . (int)$this->language->getId() . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);


return $query->rows;
}


if you are putting the qty on the bestsellers you'll run into the same problem as it's cached as well.

New member

Posts

Joined
Tue Dec 01, 2009 12:45 am
Who is online

Users browsing this forum: No registered users and 91 guests