[MOD] Stock levels in Order Add/Edit Ajax Product Results

For Articles relating to more than one ISC version
Post Reply
Brandeline
Posts: 76
Joined: Thu Sep 16, 2010 4:12 am

[MOD] Stock levels in Order Add/Edit Ajax Product Results

Post by Brandeline »

This is my first contributed mod, so be gentle :D

My customer service department asked me for this change to make it easier to take phone orders. Our install of 5.5.4 was behaving erratically in policing available items while placing orders. Sometimes it would warn of insufficient stock, and sometimes would not, so my customer service people were having to look up stock levels on items manually to be certain it was available.

6.1.1 seems to be policing this more effectively, but I went ahead and did the mod anyway as it will be easier when talking with customers not to have to add the item to the order before getting feedback from the cart on stock levels, or play guess the stock level if there are less available than the customer wants.

Please note that to keep this manageable for what I personally needed, I made one huge assumption here, and that is that all products are being tracked in inventory, and that product variations are not being used. You can probably make changes yourself if those assumptions are not true for you. This mod is for 6.1.1.

1. Open: /admin/includes/classes/class.remote.orders.php
Find the function editOrderItemSearchAction() and find this code around line 1360:

Code: Select all

				$results[] = array(
					'id'				=> $product['productid'],
					'name'				=> $product['prodname'],
					'link'				=> prodLink($product['prodname']),
					'sku'				=> $product['prodcode'],
					'isConfigurable'	=> $isConfigurable,
					'price'				=> $price
				);
Replace with:

Code: Select all

// MOD Added Inventory Level to results array so customer service can see it immediately. -LA
				$results[] = array(
					'id'				=> $product['productid'],
					'name'				=> $product['prodname'],
					'link'				=> prodLink($product['prodname']),
					'sku'				=> $product['prodcode'],
					'isConfigurable'	=> $isConfigurable,
					'price'				=> $price,
					'inventory'			=> $product['prodcurrentinv']
				);
Then open: /admin/script/order.form.js
and find this code around line 1112

Code: Select all

				
					var sku = '';
					if (result.sku) {
						sku = result.sku + ' / ';
					}
					
					var details = $('<div class="productDetails">' + sku + result.price + '</div>');
and replace with

Code: Select all

				var sku = '';
					if (result.sku) {
						sku = result.sku + ' / ';
					}
					
					var inventory = '(N/A)';
					if (result.inventory) {
						inventory =  ' (' + result.inventory + ' in stock)';
					}

					var details = $('<div class="productDetails">' + sku + result.price + inventory + '</div>');
pitorian
Posts: 31
Joined: Mon Aug 17, 2009 9:55 am

Re: [MOD] Stock levels in Order Add/Edit Ajax Product Result

Post by pitorian »

Works like a charm, it would be good on the options also, to save mispicking an item that is out of stock with sizes or flavours.
Post Reply