Page 1 of 1
Displaying quantiy available.
Posted: Wed Nov 18, 2009 6:08 am
by SoCal
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 ...
Re: Displaying quantiy available.
Posted: Wed Nov 18, 2009 9:08 am
by Daniel
I think I already added this feature.
it should be under settings.
Re: Displaying quantiy available.
Posted: Wed Nov 18, 2009 9:23 am
by SoCal
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
Re: Displaying quantiy available.
Posted: Thu Nov 19, 2009 4:34 am
by SoCal
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
Re: Displaying quantiy available.
Posted: Tue Nov 24, 2009 7:16 am
by SoCal
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
Re: Displaying quantiy available.
Posted: Tue Nov 24, 2009 7:48 am
by Xsecrets
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.
Re: Displaying quantiy available.
Posted: Tue Nov 24, 2009 9:36 am
by SoCal
Thanks,
I'll give it a shot and report back.
socal
Re: Displaying quantiy available.
Posted: Wed Nov 25, 2009 12:19 am
by SoCal
Xsecrets,
Thanks ! That worked great.
Re: Displaying quantiy available.
Posted: Wed Nov 25, 2009 3:16 am
by SoCal
Hello Xsecrets ,
How could I do the same on the Category>product
page as well ?
Worked great on the home page.
Re: Displaying quantiy available.
Posted: Wed Nov 25, 2009 4:17 am
by Xsecrets
in catalog/controller/product/category.php find around line 145
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.
Re: Displaying quantiy available.
Posted: Wed Nov 25, 2009 5:54 am
by SoCal
That worked great.
Thanks alot.
socaL
Re: Displaying quantiy available.
Posted: Tue Dec 01, 2009 4:30 am
by socal2
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/
Re: Displaying quantiy available.
Posted: Wed Dec 02, 2009 11:09 pm
by socal2
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.