Inventory API Manager for uc_stock

Contrib type: 
Module
Status: 
Uploaded for testing
Moderation: 
Not ready for moderation
Latest version: 
1

Downloads

Compatibility: 
Ubercart 1.x

This module allows uc_stock to act as an inventory manager for Inventory API. This allows the prevention of people to add a product to the cart when it is out of stock.

PreviewAttachmentSize
uc_stockstub.zip2.44 KB
TimK's picture
Offline
Joined: 08/18/2007
Juice: 147
Works great!

Works great!

I'm running RC4.

Which version of uc_inventory_api are you using?

I used 1.5 by Cpill.

I think TR may have a newer version. See post: http://www.ubercart.org/comment/11193/Re-Ryan-said-I-know-CpILL

Cheers.

AttachmentSize
uc_inventory_api_1.5.zip 65.86 KB
littly_kitty's picture
Offline
Bug Finder
Joined: 01/20/2008
Juice: 155
Using this module with multiple attributes.

This is an excellent module. However, it doesn't work as 'smoothly' as it could when using a product that has multiple attributes.

When you create a product, a "Main SKU" is created for the product.
When adding attributes, you can created separate "Attribute SKU" which have their stock levels tracked separately from the "Main SKU".

However, the "Add to Cart" button is only replaced with a "out of Stock" badge when the Main SKU reaches zero stock.
This creates a problem, as the "Attribute SKUs" may be in stock even though the "Main SKU" is not in stock (as a result, the customer is unable to order the "attribute SKUs").

Although you can disable stocking checking of the "Main SKU" to prevent this, the "out of stock" badge will no longer appear when the "attribute SKUs" reach zero stock. In such an instance, the module DOES prevent purchase of the out of stock attributes. However, the customer only sees the out of stock message when they try to add an attribute to cart.

This creates a slight usability issue, as the customer may end up trying to add every attribute to the cart before realizing that none of them are in stock.

Is there anyway to overcome this? I guess the best way would be if the "Main SKU" stock level was automatically adjusted to reflect the total number of "Attribute SKUs" in stock. Is there anyway of doing this?

72dpi's picture
Offline
Joined: 10/07/2007
Juice: 134
Sweet Webmasterkai,if this

Sweet Webmasterkai,

if this takes off where the Inventory API stopped, then poeple here are going to be very happy.

I only deal with 1 main product of each, so am not to worried about the last point, but yes, that is an issue. All attribute stoick items should be included.

Will check it out.
Thanks for your contrib!

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Inventory API Manager for uc_stock

Wow, brilliant idea! I made the API but didn't think of making a wrapper Manager for the new uc_stock module, but i guess that was the point of the API separated from the actually stock tracking logic. Still I'm amazed that the API is working OK with all the changes that happened to UC up to version 1.0. Good work old man!

Uberdevelopment www.tsd.net.au/blog

TimK's picture
Offline
Joined: 08/18/2007
Juice: 147
Only Products With Attributes

Hi.

The module seems only to 'check availability' for products that have attributes.

For products that do not have attributes, and that are out of stock, the button still reads 'add to cart' instead of saying 'not available'.

Not sure if I am missing something?

Any ideas?

Am using uc 1.3

aara's picture
Offline
Joined: 11/08/2008
Juice: 4
Bug fix for uc_inventory_api_v11

See also http://www.ubercart.org/contrib/132 ...

Fixes availability of button "Add to cart" for product node
when stock level of this product == amount of this product in cart.

You can simply find this strings in uc_inventory_api.module :

if(!uc_inventory_api_can_add($product->model, $form['qty']['#value']))
{
$form['submit']['#disabled'] = TRUE;
$form['submit']['#value'] = t('Out of stock');
}

And replace it with this one :

if(!uc_inventory_api_can_add($product->model, $form['qty']['#value'] + 1))
{
$form['submit']['#disabled'] = TRUE;
$form['submit']['#value'] = t('Out of stock');
}
AttachmentSize
uc_inventory_api_v11fix.zip 8.28 KB
wxman's picture
Offline
Joined: 01/11/2009
Juice: 51
Re: Inventory API Manager for uc_stock

This module works great for all my projects. There's just one thing I'm trying to modify without any luck. I have one site that's doing paid classes that use the paid events module. Right now when the classes are full, which is set by the stock levels, it says "Out of stock". That's fine for now, but I would love to figure out how to have it know when it's an event, say something like "Classes are full" instead. I've been trying to do this from the template.php file, but haven't had any luck.

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Ya, I guess when it does the

Ya,
I guess when it does the transactions approved which puts the stock level to zero then you would trigger an event like "Stock depleted", for example. This would be at the API level as it interacts with the rest of Ubercart.

I might be revising that module as I intend to integrate with a third party stock tracking system so this will go in my notes. I want to integrate with the 'Acions' in Drupal 6 so it will be for UC2.

Uberdevelopment www.tsd.net.au/blog

wxman's picture
Offline
Joined: 01/11/2009
Juice: 51
Re: Ya, I guess when it does the

The site that has the class sales is a Drupal 5 site, so I hope your new design will work there.

Is there no way to alter this form like you can with other with update_form? Sorry if that makes me sound a bit ignorant.

talbone's picture
Offline
Joined: 06/06/2008
Juice: 87
Re: Re: Inventory API Manager for uc_stock

you can use the strings override module for that - http://drupal.org/project/stringoverrides.

chourmovs's picture
Offline
Joined: 02/22/2009
Juice: 52
It's still planedI'm very

is it still planed ??
I'm very interested by this UC feature

Gavalar's picture
Offline
Joined: 12/24/2008
Juice: 101
Re: Inventory API Manager for uc_stock

Is there any plans to prt this to Ubercart 2.x?

As inventory_api doesnt seem to work on 2.x

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Re: Inventory API Manager for uc_stock

I was thinking about it. Might need it for my own client. If it does happen then in the next 2-3 weeks.

Uberdevelopment www.tsd.net.au/blog

Gavalar's picture
Offline
Joined: 12/24/2008
Juice: 101
@CpILL: You'd be a legend if

@CpILL:

You'd be a legend if you did Smiling

cybertoast's picture
Offline
Joined: 12/25/2008
Juice: 33
Re: Re: Re: Inventory API Manager for uc_stock

CpILL, have you made any progress with the UC2/Drupal6 port? I just ran across your thread and am thinking of going down this path, but don't want to be redundant. Thanks.

CpILL's picture
Offline
Early adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/08/2007
Juice: 550
Re: Re: Re: Re: Inventory API Manager for uc_stock

nope, ain't started yet. please be my guest Smiling

Uberdevelopment www.tsd.net.au/blog

rwheindl's picture
Offline
Joined: 03/11/2009
Juice: 10
Stock at Zero Problem

I think I found a problem with this module. When the inventory reaches 0, the out of stock button is not displaying on my site.

As I understand the below function, if a case where $amount=0 and (integer)$stock_level also is 0, it returns true. If 0=0, that's true and with CAN_BUY, we'd want to return false if amount@0=stock@0.

OLD code:

function uc_stockstub_inventory_can_buy($sku, $amount = 0)
{
$stock_level = uc_stock_level($sku);
if($stock_level!==FALSE)
{
if($amount <= (integer)$stock_level)
return true; // There is enough
else
return false; // Not enough
}
return true;
}

NEW code:

function uc_stockstub_inventory_can_buy($sku, $amount = 0)
{
$stock_level = uc_stock_level($sku);
if($stock_level!==FALSE)
{
if((integer)$stock_level < 1)
return false;
elseif($amount <= (integer)$stock_level)
return true; // There is enough
else
return false; // Not enough
}
return true;
}

After making this change in my site uc_stockstub.module, the "Add to cart" button is now properly changing to "Out of stock" when inventory reaches 0. I hope this will fix this condition and others will benefit from this information.

AkaTako's picture
Offline
Joined: 05/30/2009
Juice: 2
BUG - apparently missing </div> for uc_inventory_ajax_form

This is the fix for comment #41 above:

in uc_inventory_api.module changed line 181
FROM: $form['#sufix'] = '';
TO: $form['#suffix'] = '';
"suffix" was spelled wrong

My site was breaking due to this misspelling. It appeared as if there was no closing div for the form.

gupa's picture
Offline
Joined: 06/04/2009
Juice: 42
Re: @CpILL: You'd be a legend if

subscribe

autopoietic's picture
Offline
Joined: 07/28/2009
Juice: 52
Ubercart 2

I also would love an out of stock solution for ubercart 2.0.

zeezhao's picture
Offline
Joined: 04/23/2008
Juice: 1075
Re: Ubercart 2
deluded's picture
Offline
Joined: 09/20/2010
Juice: 5
Out of stock solution - try yobiz

For an out of stock inventory management solution that works with ubercart, you might want to try the Yobiz inventory management app. It's currently in trial period so you can evaluate.