This is an Inventory API, which hooks into Ubercart and provide a User Interface for inventory management while protect 'Inventor Manager' (business logic) which can be ether 3rd party or other Drupal modules, from changes in the UC code base. Included is a fully functional example IInventor Manager I've called 'Simple Stock Levels' which does basic stock level tracking.
The Simple Stock Levels module allows you to associate a 'quantity' with an SKU (tracking number, serial etc) and stops the purchase of products with that SKU if the quantity drops to zero. There is also 'Is Tracked' on/off switch for each product so you can turn tracking on and off for a product easily. Updates adjusts the stock levels when the order is updated in the admin backend.
Simple Stock Levels Manager isn't meant to cover all possible situations thats why I separated the business logic from the interface API. If the Simple Stock Levels Manager doesn't do exactly what you want you can modify it and then choose your custom manager to handle changes in stock. This is ideal id=f you have an external system that you want to integrate with Ubercart via SOAP or XML-RPC say.
The Inventory API does on-the-fly availability checking via Javascript (Ajax) that asks the chosen Inventor Manager if the current user (given their current cart contents) can add more of a given product to their cart and disables the 'Add to cart' button if they aren't. This allows the Inventor Manager to retain all the custom business logic needed to make this decision and so allow for more consistent behavior and simpler code design (its hoped).
Quick start guide
After Übercart is installed:
1. Install the "Inventory API" and optionally the "Simple Stock Levels" Inventory Manager module at 'admin/build/modules' and which are grouped under 'Ubercart - Inventory'. If you have a custom Inventory Manager then install that instead of "Simple Stock Levels".
2. Select which Inventory Manager you will be using at 'admin/store/settings/inventory'
3. Create/Edit a product and you should get a 'Stock levels' panel on this form. If the product has attributes then you can enable tracking and set the quantity in stock on that products Adjustments tab.
Done.
Change Log
- 1.11
- Fixed a bug which was not updating products without atributes when they submitted their the edit product form.
- 1.10
- Fixed the Ajax for IE6&7. Again.
- 1.9
- Fixed the Ajax for IE6&7.
- Added code to Simple Stock Level which removes stock level data when the product (node) is deleted (untested)
- 1.8
- Fixed a bug for product without attributes. The "add to cart" button gets disabled and says "Out of stock" now.
- Fixed a spelling mistake

- 1.7
- Simple Stock Levels Manager now updates the stock levels when an order updated or deleted in the administration backend interface.
- 1.6
- Made sure the fixes in 1.5 were uploaded
- 1.5
- Fixed a dependency bug that assumed the uc_attribute module was active.
- Fixed a HTML bug which forgot to close a DIV around the add to cart form
- 1.4
- Bug fix for default value thanks to c0psrul3
- Reworked Ajax status checking for products with attributes
- Intergration with the CSV Import module
- 1.3
- Fixed bug where the quantities were not getting decremented properly thanks to jetskier79 for posting a solution.
- 1.2
- Removed dependence on the "uc_attributes" module.
- Fixed an Ajax bug that was related to sites setup not in the root of the domain.
| Attachment | Size |
|---|---|
| uc_inventory_api_v11.zip | 30.01 KB |

Re: Inventory API & Simple Stock Levels
I wondered about the possibility of not displaying attributes for any attributes that might be out of stock. IE, If you have a site of shirts, and Black / Mediums are out....Don't allow the combination of black / medium.
Ultimately, it seems like this would be faster overall than using the ajax check each time a new attribute combination is chosen.
minor bug
in uc_stocklevels.module
in function _uc_stocklevels_get_details
I replaced
$result = db_query('SELECT * FROM {uc_stocklevels} WHERE model = \''.$sku.'\'');
with
$result = db_query("SELECT * FROM {uc_stocklevels} WHERE model = '%s'", $sku);
works better IF you have a ' in the sku's (and is more secure as well)
Attributes module dependency
I didn't have the Attributes module enabled and got SQL errors that table uc_product_adjustments didn't exist. The Attributes module should be a dependency for enabling the module I think.
@jetskier79 I suppose its
@jetskier79
I suppose its possible but more complex as you have to refresh the list on each change of the attributes, which means you copy a 'n' dimensional matrix for all the combinations of all the attributes and their stock levels (which I have done on a big site). If you have more than 2 attribute combination the problem becomes very ugly.
The other reason behind the Ajax check was so that 3rd party inventory managers, with their own business logic, could be integrated and this logic kept in one place, simplifying the design. The whole front end could be changed to accommodate this but I think the UI needs to be rethought first.
@catorghans@drual
thanks for that. I should change all the SQL calls like that, I was just being sloppy
@francishsu
I thought I'd fixed the attributes module dependency? I'll have another look, but which screen did you get this error on, and are you using 1.4?
Re: @jetskier79 I suppose its
Actually I'm using 1.3. Is 1.4 available for download elsewhere? Looks like you have already addressed the issue in version 1.4.
As far as the screens where I got the error, it was basically things like the Product administration screen and browsing through the catalog.
Attributes
FYI, it seems the Inventory API & Simple Stock Levels REQUIRE product attributes to be enabled.
How should the attributes work for in stock amount?
I can't seem to get the quantity in stock to work right when using the adjustments tab for a product. Let's say I have a hat in my inventory. It comes in red, one hat, and blue, three hats.
On the product tab, I put 4 in for "Number in Stock". When I go to the adjustment tab, both red and blue have a 4 for "Quantity". If I put a 1 for Red and a 3 for blue, after I click submit both "Quantity" fields come back as a 1 and the "Number in Stock" changes to 1.
If I add the red hat to my cart, then try adding the blue hat, I'm told the hats are out of stock.
Seems like the attributes don't really get tracked separately? Am I missing something?
I'm on ubercart Alpha7c using the v1.3 of the Inventory API and Simple Stock Levels.
Re: How should the attributes work for in stock amount?
All SKU's (model) have to be unique.
By default, the options get the same SKU as the product.
If you make them different and then adjust the qty, it will work.
Re: Re: How should the attributes work for in stock amount?
Ah ... of course! Working wonderfully!
Sold out items
I have a weird problem, items that are sold out are still available for sale, however if I put a products view in a block the "none left" button shows properly.
Once I've fixed this problem what I really need is a way to remove items completely that are sold out.
Any ideas?
Re: Sold out items
Don't know about the first problem. Check all the usual: 'is tracking' is set, SKU is set and unique, etc (I should make an FAQ for this).
The second issue you really want to change the 'publish' flag on the node to 'false' as removing it might mess up your order tracking, accounting etc. You could:
1. try extending this modules code directly
2. write your own module that extends this module
3. write your own inventory manager that plugs into the API that does this.
I think 3 is the best bet as the pluggable nature of the API was designed to handle people with particular tracking requests.
Re: Re: Sold out items
Thanks, unfortunately this is beyond my ability
Re: Inventory API & Simple Stock Levels
does this work with the latest svn of ubercart?
Cancelling orders and adjusting inventory
I've noticed that when I cancel or remove products from an order, the inventory count does not increase. Also, when I edit an order and add or remove products, the inventory count does not fluctuate correctly. Does that mean anytime I make a change to an order I have to manually adjust the inventory so that it is accurate?
Thanks
Re: Cancelling orders and adjusting inventory
Yep. There is a problem with the UC hooks so update events are not notifying the inventory API. I remember noting this but its up to Ryan or Lyle to do something bout that (or they might have and I'm not aware of it)
spelling error
Just starting to have a play with this and found a typo in the simple stock module.
On the edit page for a product, in bold:
Tracking options:
Track stock levels for this product?
Simpel Stock Levels track the stock for this item. If not checked then customers will always be able to add this item to their shopping cart.
also wanted to test the water to see if there was any movement on other modules in devel using this API?
Re: spelling error
Thanks for the spell check
Haven't heard of any. I have made some updates improving the Ajax reliability and allowing i to work in conjunction with another module I have made which replaces the select list of attributes with a radio button list of images. Other than that nobody has contributed any Inventory Managers. I guess these would nearly always be specific to the job/site. I'm always open to include any contributions.
Re: Re: spelling error
im using the latest stable version of the ubercart, and when adding or modifying products it sets the track inventory even if i do not have it checked. I do not recall seeing any js errors. any thoughts?
thanks
$is_tracked
change in uc_stocklevels.module
~ line 139
$form['table']['body'][$key]['is_tracked'] = array('#type' => 'checkbox',
'#default_value' => $stock_level->is_tracked, <=== THIS ONE!
'#prefix' => '<td>',
'#suffix' => '</td>'
);
and
~ line 180
function uc_stocklevels_product_node_form_submit($form_id, $values)
{
if(isset($values['quantity'])) // If there at attributes then this will not be set
{
// Convert the 'is_tracking' option to a boolean (1 or 0)
$is_tracked = ($values['tracking_options']['is_tracked']) 1: 0; <== THIS ONE TOO!
$detail = _uc_stocklevels_get_details($values['model']);
should fix the default "1" value for column "is_tracked" in table "uc_stocklevels"
Re: $is_tracked
thanks mate, have updated and will release a new version with your changes.
Inventroy MySQL Error
Gave "uc_inventory_api_v1.4.zip" a try. End up with the following error on each of my 3 sample products.
"user warning: Table 'jewelrycart.uc_product_adjustments' doesn't exist query: SELECT * FROM uc_product_adjustments WHERE nid = 3 in C:\apache2triad\htdocs\drupal_5.2\includes\database.mysql.inc on line 172."
Any suggestions...
Thanks.
Jim
Re: Inventroy MySQL Error
I have this problem too! =(
Re: Inventroy MySQL Error
I thought I'd fixed this already. The attachment here should fix it. Let me know and I'll post it above as the next version.
Re: Re: Inventroy MySQL Error
Oh, thank you, CpILL, you realy help me! This version is working! =)
But I've saw another problem.
I have in my warehouse 10 disks (for example), and I've ordered 1 disk, and in my warehouse remains 9 disks, but I've canceled my order, and also in my warehouse remains 9 disks, but should be 10 disks! Can you edit your code in this module??
Thank you! =)
Inventory Install Instructions
Have downloaded version 1.5 and un zipped. Normally place this in the Drupal > modules folder with the other Ubercart modules. However, noticed that I have two files that are unzipped.
One is "uc_inventory_api" at 84.2 K and the other is "__MACOSX" at 246 bytes. I assume that these both get placed in the modules folder. Do I have to also run "mysite/update.php"? I would assume not, but just want to make sure that the inventory module is installed correctly and the the DB table is created and updated as needed.
PS Looked for an install text file in the download but could not locate one that would address the how to install correctly question.
Thanks,
Jim
Inventory
Installed version 1.5 and all is working.
Thanks for the updated version.
Jim
@Alaska Thanks for the
@Alaska
Thanks for the feedback Jim, I'll post up the v1.5 file as the main one now.
@dimon_td
ya, this is an issue. I'm not sure if there is a hook to handle order changes thought the Admin. There is a new event system that the UC boys have just recently integrated, I'll check it out... at some point.
Inventory/Simple Stock Block Movement
Using localhost and Apache 2 Triad to test both Drupal and Ubercart. Using a 3 column theme and tested both Aurora and Garland with the same results.
When Simple Stock Levels 1.3 and Inventory 1.5 are enabled the left and right columns are both moved to the center. In the admin node it looks fine, but when logged out the site user will see one column with no side columns. (i.e. both left/right are correctly setup in blocks)
When Simple Stock is removed from Store Config and then Simple Stock and Inventory from enabled modules, then all return to normal. Maybe I missed a check box someplace. Always a possibility with Drupal and add ons.
Odd behavior - Any fixes, as it would be nice to use these two modules as the site has one of each item to sell with no backup inventory.
Thanks,
Jim
Update on Blocks Added Images of Site
Have attached two images. One of the site working properly called full width. The other is narrow width when both Inventory and Simple Stock Levels are activated in admin > modules. Note: site returns to normal when both modules are deselected.
Did notice that all of the left column blocks are missing. Only the center and right are displayed. Both now in the center column with missing left and right columns.
Jim
Re: Update on Blocks Added Images of Site
curious, I'm guessing that there is a tag thats not being closed. i fixed the only instance of this I could see in 1.5. Can you see any HTML errors? If your using FireFox perhaps try the HTML Validator Add-on.
Strange Results with Inventory
Thanks for the look at the interesting display with the Inventory/SSL modals activated. Have looked at the page in both IE 6 and FF and both display the same. May take your suggestion as looking at the code side by side with working vs non working page and see what can be seen.
Perhaps when Inventory is activated it causes an error that has always been present in Drupal. Or Inventory places its own error into the code and breaks the Drupal page. It is tough to see what the action is at this juncture.
Others seem to have this working so not sure what the issue is. Using Drupal 5.3 and Uber E. So far the cart works well but only when Inventory and SSL are not used. What is interesting is that this is the 2nd install that has had the same issues. Used Drupal 5.2 and Uber E on the computer as localhost with the same exact results. Then upload an entirely new site to the server. Same results. At least it is consistent!
Please keep me posted on possible solutions.
Jim
CpILL: Here are two text
CpILL:
Here are two text files containing all of the code from the home page. The broken is when SSL and Inventory are enabled.
Looked for an extra or missing "div" tag but both scripts look the same. Noticed some additional JS at the top of the page in lines 29 - 36 as follows that only appears in the broken site.
var base_path = "/";
var lang_add_to_cart = "Add to cart";
var lang_not_available = "Not available";
var lang_checking = "Checking availability...";
var node_id_list = new Array();
var attrs_list = new Array();"
Did notice that Oslinux will trade a solution for a neckless.
Jim
CpILL: Did a comparison of
CpILL:
Did a comparison of the code from the working and non working home page. Here is the result in a Word document. The yellow highlights indicate the code in the non working page that is different from the working page. The same code repeats for the other product form pages.
Take a look and let me know if you see anything that would break the page or cause Drupal to hiccup when SSL and Inventory are in use.
Thanks,
Jim
Re: CpILL: Did a comparison of
ya, seems the v1.5 download wasn't the latest file so the HTML fix I did wasn't active. should be OK now. Give it a go.
Fixed
CpILL:
Thanks so much for version 1.6. That worked well on the desktop PC under Localhost. However when I just overwrote the files on the live server it would not work. Had to first totally delete version 1.5 and then FTP 1.6 to the server.
In any event, it looks like it is a go at this point.
Thanks again.
Jim
Inventory Refresh
When an order is canceled by the store administrator in the Inventory module,the "Stock levels Number in stock: 0 The number of items Übercart is allowed to sell." is not updated. Is that what others are seeing in product settings?
i.e. there is one item to sell. The number in stock is set to 1. When the order is completed by the customer, Inventory sets this to 0 indicating no stock available. And Uber will display the message "Sorry, there is not enought in stock to add this to you cart.".
Should inventory be reset from 0 back to 1 when the store admin cancels an order?
Looks like two spelling issues - enought should be enough and you should be your. Found the text in uc_inventory_api.module and uc_inventory_api.module.svn-base .
Is this the correct location for making changes in this text??
Jim
Hi Jim, ignore
Hi Jim,
ignore "uc_inventory_api.module.svn-base" or anything with ".svn" in the name. This is my version trackers (Subversions) junk. "uc_inventory_api.module" is the place to make the change. Thanks for the corrections. The old dislexica is acting up again
There is an issue with changes to orders in the admin not reflexed in the stock levels. At the time of writing this there was no way for me to hook into the admin to know when an order had been canceled or updated. The UC team have changed the event system since and now it should be possible... when i find the time. I need this myself so should be soonish.
File Change
CpILL:
Changing one file sure does make it easier. Thanks for the suggestion.
That will be a nice update to allow the admin to cancel an order and update the inventory. So far no issue, but it will be a great enhancement once it is implemented.
Not sure if I saw this happen or just imagined it.... When stock inventories are at zero the "add to cart" button should say "sold out" and be non clickable. The way it works now is that the button has to be clicked in order to see the sold out message on the next page. That might make a customer unhappy especially if they really wanted that one item. In many cases with a lot of inventory, it will make no difference. But with sites that only have one of each item, it does become important.
Or the site admin could have a check box that would provide a selection when sold out. That would be either have the sold out button displayed or have the entire listing removed including text and picture. However, if that were to happen then there should be a way to recover the text and image if that order were to be canceled and the inventory once again brought back to one, etc. The best approach would to use just the sold out text. Seems simpler and one less thing to worry about.
Jim
Alaska (aka Jim): It should
Alaska (aka Jim):
It should do an Ajax call when the page loads and disable the button and change the text to "Checking..." then ether say "Sold Out" if the items isn't available. Are you getting Javascript errors on any page with an "Add to cart" form on it?
Sold Out
CpILL:
Guess that I was correct in that I did see that button change at one point in the life of the site.
Just now checked both my localhost site and the live site. Both do the same when inventory is at zero. The message is at the top of the home page as shown in the attachment. When looking at the item which is down the page; no sold out is listed and the button is still active. And if clicked, once again it will display the same top of page message.
There are no warnings on the page or in the Drupal log.
There are a number of Drupal modules that are either non selected or removed from the server. Let me know if a specific module has to be in use for Ajax to make the specific call.
Having another issue with a call back for In Store Pickup but that should not be related to this issue. http://ubercart.org/forum/support/1556/store_picklup_valid_callback_erro...
It would be interesting to see why the sold out button once worked but not is not functional. Interesting!!!
Jim
Page Code
CpILL:
Not sure if this is the issue or not. Did not locate this CSS class as there is no CSS style sheet in inventory. Perhaps it is being accessed in some other way.
<div class="uc_inventory_ajax_form">Here is the code for the item that has zero inventory. It looks the same as the code from an item that has a lot of remaining inventory.
<div class="content"><div class="product_image"><a href="http://localhost/drupal_5.2/files/4993.jpg" title="4993.jpg" class="thickbox" rel="field_image_cache_1"><img src="http://localhost/drupal_5.2/files/imagecache/product/files/4993.jpg" alt="4993.jpg" title="4993.jpg" /></a><br /></div><p>The accent area of this necklace contains five Sun Stones set off on both sides by a daisy spacer, Rhodonite, Unakite, and a Quartz Faceted Rectangle bead. The non-accent portion of the necklace is a pattern of Czech glass, frosted bead, and a rose bead. (Click on image for larger view)</p>
<div class="display_price">$24.95</div><div class="add_to_cart"><div class="uc_inventory_ajax_form"><form action="/drupal_5.2/node" method="post" id="uc-product-add-to-cart-form-4">
<div><input type="hidden" name="qty" id="edit-qty" value="1" />
<input type="submit" name="op" id="edit-submit" value="Add to cart" class="form-submit" />
<input type="hidden" name="form_id" id="edit-uc-product-add-to-cart-form-4" value="uc_product_add_to_cart_form_4" />
<input type="hidden" name="uc_inventory_nid" id="edit-uc-inventory-nid" value="4" />
<input type="hidden" name="uc_inventory_aids" id="edit-uc-inventory-aids" value="" />
Looks like this maybe the code that causes the action to change the button from "add to cart" to sold or the call made by div class when inventory is zero.
<div class="display_price">$24.95</div><div class="add_to_cart"><div class="uc_inventory_ajax_form"><form action="/drupal_5.2/node" method="post" id="uc-product-add-to-cart-form-4">Also using version 1.6 of Inventory and Uber 7E.
Let me know about any fix.
Thanks
Jim
Hi all, I just wondered
Hi all,
I just wondered about this question:
"I have in my warehouse 10 disks (for example), and I've ordered 1 disk, and in my warehouse remains 9 disks, but I've canceled my order, and also in my warehouse remains 9 disks, but should be 10 disks! Can you edit your code in this module??"
Thank you! =)
Inventory Now Working
CpILL:
Now have the module working 100% on localhost. Still no go on the live sites.
Had to start over with the localhost setup and remove all of the files and the DB. Now Inventory, Simple Stock Levels and In Store Pickup all work including the nice sold out box.
Any idea of why it took a new install to make it work? Perhaps something in the DB was not updating correctly.
Will have to most likely do the same to get the live sites to work. But first will add some of the additional modules to make sure that none were missing causing the issue.
Thanks for the assistance.
Jim
Order Cancled
I think that CpILL indicated that when an order is canceled by the admin the stock levels do not reset. This is an option that he would like to add to the code as you have suggested as others have the same need.
Jim
Comment by CpILL
Here is the comment made on Oct 26th...
"There is an issue with changes to orders in the admin not reflexed in the stock levels. At the time of writing this there was no way for me to hook into the admin to know when an order had been canceled or updated. The UC team have changed the event system since and now it should be possible... when i find the time. I need this myself so should be soonish."
Jim
Re: Comment by CpILL
Thanks Jim, I also added to the above description, in bold:
* * * NOTE: Changes to an order from the admin do not affect the stock levels at this time! You will have to manually do this for now. This will eventually be changed. * * *
but sadly there is no web development trick that will get people to read what is under their nose.
Is Inventory MACOSX File Needed?
CpILL
Notice that I end up with two files when unzipping.
uc_inventory.api
and
__MACOSX
Are these both required? If not which one can be removed from the Drupal modules?
Jim
MACOSX
Deleted __MACOSX from the server. Looks like that file was some material left over from code development. Not sure how it ended up in the zip file.
Jim
Re: Re: Comment by CpILL
CpILL, oh, thank, I shall wait..
uc_stocklevels.module with inventory lists
Hi you all, I´ve upgraded uc_stocklevels.module to be usable on one site I'm developing. The main problem is that there was no place to see how your stock is evolving. I've added:
Some ideas I want to add soon:
I've attached only the uc_stocklevels.module to replace the old one, only that is needed, rebuild your menu cache in order to have the new menus and links available. It's working for me and I would love to see others comments and suggestions. The more people using it the more things we'll be able to improve
Re: uc_stocklevels.module with inventory lists
WOW. I'll check it out and replace the existing one if its looking good. If people want to use this immediatly then you can just rename it (and all the functions), install it via the "Admn > site building > modules" menu and then choose it as the active stock manager in the stock levels config. But I think I'll just replace mine with this
I haven't looked yet but do your reports intergrate with the "Admin > Store > Reports" menu? I know Ryan was going to allow links to be placed in there (why not normal Drupal sub menus?)
Nice work jorditr!
Re: Re: uc_stocklevels.module with inventory lists
You do just use a normal Drupal submenu.
Any link below /admin/store/reports will get listed on that page.
New Stock Levels
Will give this a try on my localhost setup and see how it looks.
Thanks for the update.
Jim
Rebuild Your Menu Cache
In your new stocklevels the statement is made "rebuild your menu cache". How do I go about doing this?
Thanks,
Jim
You're welcome and further developement
Thanks to all the ones that are checking it. I sincerely believe that the inventory control listing is a b-a-s-i-c feature on a shop
So, thanks, first of all to CpIll for the API which allows having inventory management.
My idea is working with anyone interested on it to stablish a solution good enough to be included in core
You see I got plans for updates I hope to face on the next days, in fact I'm already involded on a big e-shop project that needs to be finished on a couple of weeks.
Alaska/Jim: The menu cache may be rebuilt or by truncating the corresponding table (maybe using phpmyadmin on your hosting provider) or by using devel.module which has some utilities for refreshing caches. Maybe you install it and see that you don't need to rebuild the menu cache because the menus are already there...
CpIll: I was thinking a lot about where should those menus by placed. Reports were quite a logical place, but finally I felt that Inventory management was more a question of "products" than "reports". Probably it's a question of nuances but for me that's the correct place, but it could discussed further. Maybe it depends more on how it evolves that could be considered "reports" or even more inside "products".
New features discussion
CpIll, Ryan, Jim, and everybody, I would like to accept suggestions and ideas for upgrading and empowering the inventory solution. Specially CpIll has a lot to say since he has created the basic API.
This thead is becoming quite long, I don't know if it could be good to continue this discussion on a new forum thread. For Ryan (who I met on Barcelona DrupalCon if he can remember) I would like also find the support for this inventory solution that could allow it to be included in core, since a good e-shop like ubercart already is becomes something of a higher level with that kind of improvements
Re: New features discussion
I agree. Even basic inventory control in 1.0 is almost essential when compared with other e-commerce systems. My recommendation would be to start an "Inventory Battle Plans" thread in the development forum listing the current work and the items folks need to fix up. Let that be a place for discussion so this contrib thread doesn't grow to epic proportions.
Once you have some ideas, you can split it up into issues in the issue tracker if you want. I haven't had much time in the past to check out the inventory stuff, but I'd like to be available for testing and code feedback. For a module to be included in core, it must at least conform to Drupal's coding standards, and I'll also check it out to make sure it's working and operating in a reasonable manner.
Battle plans
Hi Ryan for your comments, I understand that a module included in core must conform a certain coding level. I invite CpIll to open that threads since he's the author of most of the code.
Truncating
Jorditr:
Thanks for the how to. It is most appreciated.
No issue with using phpmyadmin. Use it all the time to see what is in the DB. Can just go ahead and truncate that table as I am good at using the delete key!
Can take a look at the DB before and after and see what the changes are along with making an export just in case, etc.
"The menu cache may be rebuilt or by truncating the corresponding table (maybe using phpmyadmin on your hosting provider) or by using devel.module which has some utilities for refreshing caches. Maybe you install it and see that you don't need to rebuild the menu cache because the menus are already there..."
Use both the inventory module (old version 1.6) and In Store Pickup. What is interesting is with In Store if "country" is not checked a warring is presented and the check out process stops. Maybe I am one of the few that do not need a country as all sales are USA only.
Jim
Cache and country
Hi Jim.
All the changes on menus (every time you add a new module or a new version or you are developing and add a new feature) are registrered on the corresponding menu table, but the systems reads the menu-cache table instead, that's why it has to rebuilt since it doesn't reflect recent changes. Just in case you don't know.
The second issue, I don't know, but maybe it's just a question of selecting USA as your country and everything will work properly
The opensource model of development.
@jorditr
Guess I'm not really that interested in getting this module accepted into core. I'm sure the UC team will write their own inventory module, as they did with the file product, and then there will be no need for this module.
Also, once I finish the job I'm working on, hopefully in a few weeks, I will not be very interested in maintaining this code and will look for someone else to take it over. I only wrote it because this is core functionality and it didn't exist at the time I needed.
I'm sure another keen developer with a need will step up to take my place.
Re: uc_stocklevels.module with inventory lists
It should be noted that 'jorditr' version of uc_stocklevels doesn't handle tracking of items with attributes (i.e. stocklevels set on the adjustments page). Also there is filtering by node type = 'product' which means products that have a class, and hence their own type, won't be picked up. If your products don't have attributes nor use product classes then it should be accurate.
Re: Re: uc_stocklevels.module with inventory lists
CPiLL, not a big issue but did you intentionally remove the code that changed the add to cart buttons to say none left or add to cart based on the inventory manager? or is it just me having another off night?
Re: Re: Re: uc_stocklevels.module with inventory lists
I completely revised the Javascript in an attempt to simplify it and make it more robust a few versions ago. Why, isn't it working now? Its going on my test setup. Whats happening for you?
small bugs
I installed version 1.7 under UC alpha 8 today. bmagistro
mentioned the button not working, and it doesn't work for
for me either. Namely, the "Add to cart" button sometimes shows
"Checking availability ..." momentarily but never shows "None left".
When stock reaches zero, a red box with the message "Sorry, there
is not enough in stock to add this to your cart." shows up at top
of the page, but the button still reads "Add to Cart".
Firefox 2.0.0.9 reports a JavaScript error:
JavaScript error in availability_check.v2.js:
line 36: if(item.value != undefined)
Error: item has no properties
Also, a couple of other minor points:
Two spelling error in uc_inventory_api.info:
Inventory trakcing API for seleting inventory sub system.
__MACOSX is still present in zip file
Problem with Uninstalling
When I installed uc_inventory_api, the only module that showed up on the admin/build/modules page was "Inventory API". "Simple Stock Levels" didn't appear in the list. I enabled "Inventory API" and it worked fine after I went to its configuration page and chose the stock manager. So it appears both modules did get installed, even though only one showed up in the list of modules.
The problem came when I tried to uninstall these modules. Since "Simple Stock Levels" wasn't on the list, I couldn't uncheck it to uninstall it. I was able to uninstall "Inventory API" just fine, but "Simple Stock Levels" didn't get uninstalled at the same time - visiting a product page and choosing the "Edit" tab would cause an error complaining about missing uc_inventory_api functions and the page would fail to display. So it seems "Simple Stock Levels" was still trying to do its thing, but now the "Inventory API" dependency was missing.
I don't understand enough (yet) about the internals of Drupal, so I can't say how to properly structure these two modules. However, as a hack, I eventually got Simple Stock Levels to show up in the list of modules by moving the install directory from site/all/modules/uc_inventory_api/managers/uc_stocklevels to site/all/modules/uc_stocklevels. Then it was a simple matter to uninstall both modules and get everything working again without inventory. Using uc_stocklevels_api version 1.7 and Ubercart alpha 8, Drupal 5.3
Re: small bugs
I didn't test the Ajax on products without attributes after I rewrote the Javascript, which is most certainly where the errors are occurring.
__MACOSX must be some inviable junk that OS-X leaves lying around. Shouldn't harm anyone and you can delete it if you want.
New jorditr version of inventory
Hi you all.
Here you can find attached a new version of uc_inventory and uc_stocklevels. Changes are:
Both provided files should replace the original ones, simply provide more functionalities without modifiying the original ones. You're welcome to test and share your opinions
Battle Plans thread
Hi, I finally have open a thread for battle plans:
http://www.ubercart.org/forum/development/1797/inventory_stock_managemen...
Maybe we can discuss there all the present and new issues
IE "Check Availability" not working
I have a product, has three attributes, small medium & large.
I have it setup where small has an inventory of 5, medium 0, and large 5.
Now, in Firefox, and Opera, when I select medium as a choice, the AJAX call seems to work fine...but in IE7 or IE6, it does not.
IE7 reports no kinds of errors, but IE6 reports something worded just like the if(item.value != undefined) error.
Thoughts, comments, wise insights?
Other than that, WORKS GREAT!!!
-Trevor
Re: Re: small bugs
ok, I think I've figured out that the if(item.value != undefined) is related to products that do not have any attributes.
I came to this conclusion as I have jrating installed, and it works just fine on products that have attributes, but is broken on items which do not. The "issue" I'm seeing using jquery is that items w/out attributes, only half of the jrating section are being displayed, the half that is missing is the vote form.
To see what I am talking about here is two products:
No Attributes -> http://ubercart.eternitydesigns.net/products/full-size-disc
W/Attributes -> http://ubercart.eternitydesigns.net/products/vango
(on the vango t-shirt, size medium is set at 0, so it should come up as not available).
I'm no javascript expert, but I've looked at the code, I just cannot seem to figure out what could be up...
Hey jorditr, It seems that
Hey jorditr,
It seems that there is an issue with your SQL:
SELECT nd.nid, nd.title, st.model, st.quantity, st.is_tracked
FROM {uc_stocklevels} AS st
LEFT JOIN {uc_products} AS pr
ON st.model = pr.model
LEFT JOIN {uc_product_adjustments} AS pa
ON st.model = pa.model
LEFT JOIN {node} AS nd
ON pr.nid = nd.nid OR pa.nid = nd.nid
WHERE st.is_tracked = '1'
The problem is your joining to the products table via the 'model', which will be different for each adjustment of the same product. So you won't be getting the product title/model back for most of the SKUs
The only way to do it for sure is to unserialise each of the 'combination' values and then query the 'uc_product_attributes' table individually to made the join. This is ugly but side effect of not being able to JOIN directly with 'combination' column, the only flaw in the UC database design I think. Lyle will have to fix it at some point but this will be a major rewrite of the uc_attributes module and all related modules.
Also when a product is deleted I'm sure the uc_stocklevels records don't get deleted (better put that in the to-do list). I haven't looked into how to capture the product deletion event.
I think what your trying to do is worth while as this sort of report will be needed but this module.
the 'combination' column :(
@trevorlee_nc
There shouldn't be any ajax call fro products without attributes as a check can be made before the form loads to see if there is any stock and then disable the button. See version v1.8 which shoudl be working correctly now.
Re: the 'combination' column :(
I see, thanks Alex for your comment. Uhmm, well, it's not so difficult to rewritte the select to take into account models more than node... I'll have a look at it.
BTW, I already say that uc_stocklevels is not properly updated. When I create a product and add inventory control for it, it adds an entry to that table. If later I decided to create attributes for it and add inventory control for them, all this entries go to the table. Now we have entries for the product as it was entered first and then for the attributes. Uhmm, maybe that's not good.
RE: IE "Check Availability" not working
@CpILL
this definatly fixed the issue with jrating, THANKS!! AWESOME!!!
however, there is still an issue with IE not picking up the change in stock levels when a product with attributes, such as small/med/large, and someone chooses a size level that is out of stock.
In this case, this url:
http://ubercart.eternitydesigns.net/products/vango
small = 5 instock
med = 0 instock
large = 5 instock
If I change the default from small to medium, the ajax call seems to work fine, and displays "not in stock".
Also, while the jrating thing is now working, the if (item.value != undefined) { error is still there when items are displayed as in the teaser list...
http://ubercart.eternitydesigns.net/
Manythings, overall again!
-Trevor
Hi Alex. I've made a quick
Hi Alex.
I've made a quick investigation on deleting information related with a node when deleting a node. Maybe could be something like this?:
<?php/**
* Implementation of hook_nodeapi().
*/
function uc_stocklevels_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
case 'delete':
if (user_access('administer inventory')) {
return db_query("DELETE FROM {uc_stocklevels} AS st
LEFT JOIN {uc_product_adjustments} AS pa
ON st.model = pa.model
WHERE pa.nid = '%s'",
$type, $id);
}
break;
}
}
?>
You're always seeing deeper on my selects, that's why I first make a proposal this time
There's more information on that on http://api.drupal.org/api/function/hook_nodeapi/5
@jorditr Thats SQL looks OK.
@jorditr
Thats SQL looks OK. I'd lose the $type from the 3rd argument, and you want $node->nid instead of $id, but otherwise that should work. I'll integrate and test it.
"If later I decided to create attributes for it and add inventory control for them, all this entries go to the table. Now we have entries for the product as it was entered first and then for the attributes. Uhmm, maybe that's not good."
Ya, I hadn't thought of this but it shouldn't be a big problem. The work around is to use a different SKU for each adjustment and to also make sure they are different from the products main SKU. This is how adjustments are meant to work I I think.
@trevorlee_nc
your right, IE is not triggering the 'onchange' event fro some reason. I was relying on JQuery to do this for me, perhaps I use the wrong event function... will look into it. Thanks for sniffing it out for me
Re: @jorditr Thats SQL looks OK.
Hi Alex. I did use I different SKU for every attributed products, that's why probably the system add them, first, there is no part deleting not used information and those are completely new product models (if I had a MC3456 products for something with three sizes then I created MC3456S, MC3456M, MC3456L, and the table registers all four models). When listing models for stock control all products appear... hmmm, unless I make a more complex select filtering whatever product which had attributes but had an entry without them. In any case we should find a solution to delete the first non-attributed entry, tables are not for holding useless information
Can't deactivate tracking
I'm using ubercart alpha8 without attributes and uc inventory v1.8.
I can't deactivate the tracking with the 'Track stock levels for this product?'-button. Even if I uncheck it, it is checked again when I go back to editing, and the Sold out button appears instead of the Order button.
what to do?
installation trouble
I'm very new to Drupal/UberCart, but I just took over admin on a site that uses both. It looks like installation of uc_inventory_api should be really elementary, even though there aren't really explicit instructions. I upload the contents of the unzipped archive (uc_inventory_api_v1.8.zip) into the directory home/[dev_path]/[sitename]/modules/, but then when I go to my admin interface at Admin > Build > Modules, neither Inventory API nor Simple Stock Levels appears. I also uploaded the module to home/[dev_path]/[sitename]/modules/ubercart/ but again no luck finding it on the front end. Am I doing something wrong here? TIA.
Questions
Hello! This inventory module looks very cool.. I've some questions about
1. Where to place this sql code?
<?php/**
* Implementation of hook_nodeapi().
*/
function uc_stocklevels_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
switch ($op) {
..
2. "Intergration with the CSV Import module"
How to integrate this with the cvs importer? What should i write in the modules/node_import/supported/ubercart/uc_product.inc file?
..if (_uc_product_node_import_is_product($type)) {
$fields = array(
'title' => 'Product: Name',
'stock_level' => 'Product: Stock level', <<< Like this?
..
Please help, if u can.. Thx
Good Luck and cheers
@CpILL Looks like something
@CpILL
Looks like something else is maybe broken with the ajax on IE.
What I ended up missing is that the check availability does work, however when the "Add to Cart" button is pressed for a product that does have that attribute in stock, the button changes to check availability, and back to "Add to Cart".
The form doesn't get processed, and nothing gets added to the cart.
-Trevor
@nicozulu 1. There is no SQL
@nicozulu
1. There is no SQL code there.
2. The API is already integrated with the CSV Importer module that I wrote.
@trevorlee_nc
your right. this is becoming a nightmare
enable/disable
Hello, I am not sure if its just me but i upgraded to the latest version and cannot stop items from being tracked in inventory (both new and existing). It seems to be defaulting to 1 when it makes the database entry even if it isn't checked. Has anyone else experienced this?
IE6/7 Working Now
@CpILL - all is right with the world once again...thanks!
Re: IE6/7 Working Now
Works perfect for me too, thanks for this awesome module!!!
A tiny suggestion
After a few days working with this module, I have one tiny suggestion... hope it can be implemented.
We have a stock of mostly one item, when it is ordered and sold, we display "Sold out". So far so good...
But when you add the item to your shopping cart, and you revisit the item, the exact same message appears (Sold out). It might give the impression that somebody just beat you to the sale and may decide not to proceed with the order!
Would it be possible to display "In shopping cart" until it is actually sold?
That would make an awesome module even more perfect!
Products With No Attributes & Out of Stock Issue
Ok, maybe, JUST maybe in all my playing around getting the attributes & check availability working, I missed that a product with no attributes, and a stock level of 0 (zero), the button appears as "add to cart". But when you click that, it goes to the next page and says:
"Sorry, there is not enought in stock to add this to your cart."
So should I be expecting this button to change, have I missed a setup step ? (this issue is in FF2/Opera/IE6/7)
(p.s. also, typo on the "enought", easy to fix locally, but something worth including on the next rel)
thanks,
-Trevor
Just checked another install I have
and this was not an issue in the 1.9 release...
anyway, an fyi, if I you need, I have two ubercart installs running 1.9 & 1.10 of the inventory manager if you need/want access.
thanks again
-Trev
Re: Inventory API & Simple Stock Levels
I have a bug with product stock management without attributes.
ATM, I use stock just to say when a product is out of stock. So I don't check track stock except for product out of stock, I check track stock and I put 0.
The bug is that I have a product that was out of stock, but now, it is in stock. And when I uncheck "track stock", it doesn't work, it say that the product is out of stock when I want to add it to my cart.
So the solution I found is to let track stock but to put 9999 in stock but this is a little ugly solution.
-> Sophia Don't push it. ->
-> Sophia
Don't push it.
-> trevorlee_nc:
It should turn the button to "out of stock" and not clickable when stock = 0 (zero) and tracking is 'on'. I have tested it and it works on my machine.
-> zmove:
It must be your luck day. Should be fixed in v1.11
Adding stocklevels to Views
Hi.
Is there any easy way to embed stocklevels into views - to have it as FIELD in views?
Thanks.
Re: Adding stocklevels to Views
ya, I guess the module would have to write a hook for views. I'm not sure what this involves as I have no need of it, but if someone ones to contribute the functions, I'll include it in the code base
v1.11
thanks, what ever you changed seems to have fixed the problem i had (im going to assume i had the same issue zmove had). thanks again