Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Showing availability instead of stock units - Basic mod Rate Topic   - - - - -

 
  • martins
  • Member
  • Members
  • Join Date: 25-May 07
  • 36 posts

Posted 03 June 2007 - 11:28 PM #1

In my situation I was interested in having stock control turned on, but was not interested in showing users the amount in stock.
All I wanted is the user to know if the product is available or not.
ie : displaying a message " Available " when the product is in stock and " not available " if it is not.
This is actually very easy to achieve, and being my first atempt with the smarty template engine was very intuitve, so I presume I will like smarty
(let me say that I have CS-cart for around a week, so I am still examining.)

To implement this you first need to create 2 Language variables. (there is plenty information on how to do that)

Variable 1 :

stock_available and give it the value of AVAILABLE

Variable 2 :

stock_not_available and give it the value of UNAVAILABE

Next we will edit the file : product_details.tpl

Now look for the code (around line 100):

<td><span id="product_amount_{$product.product_id}">{$product.amount} {$lang.items}</span></td>

and delete it, or coment out by inserting it betwen {** and **}

Now insert in substituition of the deleted code

<td>
	{if $product.amount >0} <strong><font color="#FF6600">{$lang.stock_available}</font></strong> 
	{/if}
	{if $product.amount <=0} <font color="#FF0000"><strong>{$lang.stock_not_available}</strong></font>			
             {/if}
	</td>

And thats it. Now if stock exists it will show the message AVAILABLE (or whatever value you decide to put in language variable), on the other hand if the item is out of stock it will show " UNAVAILABLE ".

This means that you can keep your stock control option turned on and benefit from its features, without letting the customer know how many units you have.

There is still a small problem, which is if the customer order 10 units, but you only have 9 units in stock, then only 9 will be added to the cart. This may confuse the customer, so I will have to work on that so that he receives a message.

I hope it helps anyone.

Kind Regards,
Martins

 
  • tjmaxwell
  • Member
  • Members
  • Join Date: 18-Jun 07
  • 55 posts

Posted 20 June 2007 - 03:52 AM #2

Thanks a lot for this. It really came in handy! :)

 
  • martins
  • Member
  • Members
  • Join Date: 25-May 07
  • 36 posts

Posted 20 June 2007 - 09:18 AM #3

I'm learning, but i like to share what I learn.
Thanks
Kind regards,
Martins

 
  • Page
  • Senior Member
  • Members
  • Join Date: 06-Sep 07
  • 491 posts

Posted 01 October 2007 - 06:08 PM #4

Did you ever sort the code for the 9 items but asking for 10 problem.

Also this does not work for a product with options - which I am trying to implement but without joy.

 
  • techman
  • Senior Member
  • Members
  • Join Date: 12-Sep 07
  • 115 posts

Posted 01 October 2007 - 10:08 PM #5

This came handy when I was thinking about it. Thanks you save my day.
TechMAN,
No one knows it all, help others to help yourself

Advertise your site in Style - Free web Link Exchange
Web Bid Directory - Get Listed Now

 
  • Lars
  • Junior Member
  • Members
  • Join Date: 18-Jun 07
  • 5 posts

Posted 15 November 2007 - 09:00 AM #6

Did you ever sort the code for the 9 items but asking for 10 problem.

Also this does not work for a product with options - which I am trying to implement but without joy.


I had the same problem. You need to edit exceptions.js

find the lines

if (pr_a[id][i]['amount']) {
				if (pr_a[id][i]['amount'] > 0) {
					document.getElementById('product_amount_' + id).innerHTML = pr_a[id][i]['amount'] + ' ' + lang_items; 
				} else {
					document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + lang_out_of_stock + '</span>';
				}
				return true;
			}
then edit the code to
if (pr_a[id][i]['amount'] == 555) {
					//document.getElementById('product_amount_' + id).innerHTML = pr_a[id][i]['amount'] + ' ' + lang_items; 
					document.getElementById('product_amount_' + id).innerHTML = "Option not here";
				} 
				else if (pr_a[id][i]['amount'] == 0) {
					document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + lang_out_of_stock + '</span>';
				}
				else{
					document.getElementById('product_amount_' + id).innerHTML = "What ever you want here";
				}

Hope this will help you.

 
  • BarryH
  • Senior Member
  • Members
  • Join Date: 03-Sep 07
  • 1459 posts

Posted 18 January 2008 - 12:20 PM #7

Hi, I am interested in this feature but would like to know if it works with V1.3.5 SP2?

I will do some more searching on the forum to see if anyone else has posted anything on this subject.

Thanks

BarryH

BarryH

 

CS-Cart v4.4.3 (Plus one being developed v4.5.2 SP2)
UK User


 
  • Page
  • Senior Member
  • Members
  • Join Date: 06-Sep 07
  • 491 posts

Posted 19 January 2008 - 03:47 PM #8

Lars - I have only just had a chance to look at this again.

Where would I find "exceptions.js" to go and edit it.

Is this the only bit of code I need to edit or do I also need to edit the template in some way.

Thanks
*** Trying to help and trying to learn ***
Running an upgraded v135sp3 to v2.0.12 on live store(05/02/10) but not really right after update by Dr SnoRocket

 
  • BarryH
  • Senior Member
  • Members
  • Join Date: 03-Sep 07
  • 1459 posts

Posted 01 March 2008 - 10:38 AM #9

I had the same problem. You need to edit exceptions.js

find the lines

if (pr_a[id][i]['amount']) {
				if (pr_a[id][i]['amount'] > 0) {
					document.getElementById('product_amount_' + id).innerHTML = pr_a[id][i]['amount'] + ' ' + lang_items; 
				} else {
					document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + lang_out_of_stock + '</span>';
				}
				return true;
			}
then edit the code to
if (pr_a[id][i]['amount'] == 555) {
					//document.getElementById('product_amount_' + id).innerHTML = pr_a[id][i]['amount'] + ' ' + lang_items; 
					document.getElementById('product_amount_' + id).innerHTML = "Option not here";
				} 
				else if (pr_a[id][i]['amount'] == 0) {
					document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + lang_out_of_stock + '</span>';
				}
				else{
					document.getElementById('product_amount_' + id).innerHTML = "What ever you want here";
				}

Hope this will help you.


I am totally cracking up!

I had this working and now it's not. Can anyone enlighten me as to how I get the above coding to work? Is there anyone who has done it?

BarryH

BarryH

 

CS-Cart v4.4.3 (Plus one being developed v4.5.2 SP2)
UK User


 
  • gugga7
  • Senior Member
  • Members
  • Join Date: 16-Mar 08
  • 277 posts

Posted 22 October 2010 - 09:26 PM #10

Reviving this thread as this is exactly what I'm looking for. For those who are familiar with Overstock, they have the availability feature that is a powerful selling feature where they show you if the item is "Low Inventory / High Risk Sellout".

Based on what was coded above, is it possible to have a similar feature in cs-cart?

Basically: when the stock of a product goes below X items, then display TEXT ("Low Inventory / High Risk Sellout")

I'm not a coder myself but I assume this shouldn't be very hard to implement...

 
  • gugga7
  • Senior Member
  • Members
  • Join Date: 16-Mar 08
  • 277 posts

Posted 18 November 2010 - 05:27 PM #11

Next we will edit the file : product_details.tpl


Does anybody know what's the equivalent of product_details.tpl that I'd need to edit for version 2.1 ?

Thanks!

 
  • Lars
  • Junior Member
  • Members
  • Join Date: 18-Jun 07
  • 5 posts

Posted 20 November 2010 - 07:30 PM #12

In v.2 of cs cart you need to edit product_data.tpl in common_tamplates folder.

There you find this code (line 158 in my file )
		{if ($product.amount >= 0 && $product.amount > $product.min_qty) || $product.tracking != "B"}
			<p class="strong in-stock" id="in_stock_info_{$obj_id}">{$lang.in_stock}</p>
		{/if}
{/capture}

Then you can edit to have more elseif commands and the text you want to show

{if ($product.amount > 1000 && $product.amount > $product.min_qty) || $product.tracking != "B"}
			<p class="strong in-stock" id="in_stock_info_{$obj_id}">{$lang.in_stock}</p>	
		{ elseif ($product.amount <= 100 && $product.amount > $product.min_qty) || $product.tracking != "B"}
			<p class="strong in-stock" id="in_stock_info_{$obj_id}">{"Low Stock"}</p>
		{ elseif ($product.amount <=10 && $product.amount > $product.min_qty) || $product.tracking != "B"}
			<p class="strong in-stock" id="in_stock_info_{$obj_id}">{"High Risk Sellout"}</p>			
		{/if}

Hope this help you

 
  • egohome
  • Junior Member
  • Members
  • Join Date: 11-Nov 10
  • 15 posts

Posted 25 November 2010 - 11:37 PM #13

Design > Appearance settings > Display In stock as a field

- if checked, in product details page, it will show : In stock 50pcs
- if unchecked, it will just show : In stock (or out of stock)

no need to edit any files...

:rolleyes: