Jump to content

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

In Stock Yes/No Mod for products with options Rate Topic   - - - - -

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

Posted 22 June 2008 - 06:18 PM #1

Someone asked me to post this sorry for the delay. I thought something might be better than nothing but sorry if it is a bit of a poor post. I am out of my depth so cannot offer any further help but it may give you what you need to make the changes and even improve on them. If so then do post back. Thanks.

A number of things have to be edited for this to work.

The product template products.tpl has to be altered to work for products without options. Details of this are elsewhere on the forum.

(And/or the products_advanced.tpl - which is the one that kicks in if you set ?? in the back end and allows multiple products to be added to the cart)

Then for products with options a java script file has to edited.

I did not sort this myself but was helped by a friend who did not know cs-cart or smarty. So it could perhaps be coded better. But it works.

For example what would be nice is if language variables could be set so that the they could be called from the different templates and the javascript and then altered if needed. This is beyond my knowledge set and I have to much on to look into it.

(Brandon ported it from 134sp3 to 135sp3 for me. I think the code was the same but the location of the javascript file is different.

So in 135sp3 public_html/classes/scripts locate the exceptions.js script.

Around line 300 make the changes as detailed.

// *****************************************  A M O U N T   I N   S T O C K  **********************************/
//
// Changes amount in stock if product inventory is in track with options
//
function fn_change_amount(id)
{
	var key;

	if (!document.getElementById('product_amount_' + id)) {
		return false;
	}

	key = '';
	for (i in pr_o[id]) {
		if (!document.getElementById(pr_o[id][i]['id'])) {
			continue;
		}
		if (pr_o[id][i]['inventory'] == 'Y') {
			key += pr_o[id][i]['option_id'] + ":" + pr_o[id][i]['selected_value'] + "|";
		}
	}
	for (i in pr_a[id]) {
		if (key == i)	{
			// Brandon 5/14/08
			//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.text_out_of_stock + '</span>';
				//}
				//return true;
			//}
			
		if (pr_a[id][i]['amount']) {
				if (pr_a[id][i]['amount'] > 0) {
					document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + "Yes" + '</span>'; 
				}else {
					document.getElementById('product_amount_' + id).innerHTML = "Not Currently";
				}
				return true;
			}
			// End Brandon
		}
		document.getElementById('product_amount_' + id).innerHTML = '<span class="price">' + lang.text_out_of_stock + '</span>';
	}
	return true;
}


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

 
  • ope
  • Junior Member
  • Members
  • Join Date: 23-Mar 06
  • 1 posts

Posted 13 February 2009 - 10:31 PM #2

Great mod!

I replaced "Not Currently" with lang.text_out_of_stock to get text from database, but it does not work when "Yes" is replaced with lang.in_stock. Can anyone help with this?