12 replies [Last post]
torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Was this information Helpful?

I mentioned this in a thread about Ryan's new Add to Cart Links API code he's working on, and wanted to start a new topic to see what the demand would be.

With our current system, we are able to create a new product but prevent it from being added to someone's cart. This is especially helpful when we have a product that's Coming Soon, or a preview of a product, etc. - that way we can announce it, even if it's not necessarily available to purchase yet.

What would it take to get something like this created? Either a new module is fine but I think this type of permission would be fairly easy to implement into core. Just a checkbox or select list that would be a boolean / yes/no value. "Can this item be added to cart?"

Unless there is already a way to do this - I have checked but came up empty handed.

I understand the UberDudes are way busy, and if this is something that wouldn't be too hard, I could attempt writing a module for it. I would just need a few pointers to get started and maybe I can take a crack at it, if that's what it takes.

What do you think, sirs?

--
Help directly fund development: Donate via PayPal!

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Able to Purchase vs. Coming Soon

I was able to do this pretty easily using CCK and creating a new module. Unfortunately I haven't quite figured out the ".install" creation process, so for now, you just have to use CCK to create a new Text field called "Available" which is a Text Select List. The two values are:

N|Coming Soon
Y|Available

Here's the only code in the module that basically checks to see if the value is N, and if so, prevents them from adding to the cart. It's pretty basic but maybe someone else can use it (I know I can.)

I really wanted to hook into the node_info and product_form hooks from Ubercart, but really just needed something quick and dirty, and couldn't find much documentation on hooking into those functions. So this is what I came up with in a pinch.

(This is in the file uc_product_coming_soon.module:

<?php
function uc_product_coming_soon_add_to_cart($nid, $qty, $data) {
 
$available = db_result(db_query("SELECT field_available_value FROM {content_type_product} WHERE nid = %d", $nid));
 
if (
$available == 'N') {
 
   
$result[] = array(
     
'success' => FALSE,
     
'message' => t('Sorry, that product is not available to purchase yet.'),
    );
  }
  return
$result;
}
?>
AttachmentSize
uc_product_coming_soon.zip 1.72 KB

--
Help directly fund development: Donate via PayPal!

stilln's picture
Offline
Joined: 02/25/2009
Juice: 105
Re: Re: Able to Purchase vs. Coming Soon

cool

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Re: Able to Purchase vs. Coming Soon

Knowing what I know now about building modules, I could probably rework this into a really small module (although I'm not sure why an option for this doesn't already exist in Core..). I'll see what I can do in the near future - I don't imagine it'd take long to write.

--
Help directly fund development: Donate via PayPal!

ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Re: Re: Re: Able to Purchase vs. Coming Soon

I'm somewhat surprised this isn't in core. In recent implementations I've worked around it by coding some exceptions that don't display the "add to cart" button for particular products, and replaces it with a Coming Soon "button" which is not clickable (and styled as being grayed-out).

imstillatwork's picture
Offline
Bug Finder
Joined: 12/27/2008
Juice: 207
Re: Able to Purchase vs. Coming Soon

This should be in CORE. It is a VITAL function to running a BASIC storefront, especially when relying on SEO and search traffic for sales, you've GOT to get the product up and listed ASAP, even if you can't sell it yet.

PepeMty's picture
Offline
InternationalizationizerNot Kulvik
Joined: 11/26/2007
Juice: 158
Re: Able to Purchase vs. Coming Soon

subscribing.

Warm regards from sunny México!
Pepe

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Able to Purchase vs. Coming Soon

Ryan and Lyle, what do you think? Want me to write a patch that adds this functionality?

--
Help directly fund development: Donate via PayPal!

kenwen's picture
Offline
Joined: 03/20/2009
Juice: 72
+several!

this definitely gets my vote - its illegal to sell products that are out of stock / coming soon in the UK and bill customers in advance without notifying them of this. Without stock control or some way to stop people ordering this can be very difficult to manage.

cheers Smiling
Ken

spiderglow's picture
Offline
Joined: 02/01/2009
Juice: 9
An idea

TorgosPizza thanks for the post is a great idea.

I want to share some additional ideas:

A) offer an option to be notificated when items are available.
B) the one im really looking into is placin a note regarding if this item is at hand (inventory > 0) or if this item is sold out and place a note of the change on delivery date and offer a discounted price for the item (this can also be affected by making the credit card payment at delivery date)

What do you think?

Visit Robosonico.com

stilln's picture
Offline
Joined: 02/25/2009
Juice: 105
Re: An idea

They already have a module that will allow buyer to be notified when and out of stock item comes back in stock http://drupal.org/project/uc_stock_notify. I'm actually interested in a module that will change the out of stock button to a back order button and allow buyer to back order and item, so they would pay first and once it comes in stock we would ship it to them. i have done some changes to the to the uc_inventory_api module to do this but I have had some problems. I'm actually willing to pay to have this and a few other things done if any one is intrested.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: An idea

That actually seems like it'd be a good addition to uc_stock_notify, or even uc_attribute_stock_filter (which I'm using on a new site I am currently developing). It could probably be patched (or maybe just hooked into with another form_alter()...)

I think it makes most sense to give users an option of what happens when an item goes out of stock: turn off the Add to Cart button, or turn it into a "back order" button. (Maybe make that a per-product option?)

--
Help directly fund development: Donate via PayPal!

stilln's picture
Offline
Joined: 02/25/2009
Juice: 105
Re: Re: Re: An idea

Yea! cause I was planning on using stock notify for my site which is a good module but there was one problem there was no way of seeing what items people wanted to be notified about so we can reorder them. Unless you went into your data base. they should of had a place in the shopping cart that showed a list of the items people wanted to be notified in a chart format with the number of people that wanted to be notified per product, the most request item, what has been reordered and how many time ect... basic product stats. But enough about that. Back to the Back order the only thing with uc_attribute_stock_filter is that it's for 6.0 only I'm still using 5. what i did was modify the uc_inventory_api module example:

else
{
// No attributes...

// If its a simple product with no attributes see if there are
// enough in stock to sell one more

$product = $form['#parameters'][1];

if(!uc_inventory_api_can_add($product->model, $form['qty']['#value']))
{
$form['submit']['#disabled'] = FALSE;
$form['submit']['#value'] = t('Back Order');
}
}
break;
}
}

This part I changes the out of stock button to Back Order and made it clickable. Next I wanna edit this:

/**
* Implement hook_add_to_cart
*
* Stop the adding of the item to cart if the Inventory Manager says 'Nay!' (false).
*/
function uc_inventory_api_add_to_cart($nid, $amount, $data)
{
// Get the products ID (SKU).

if(empty($data['model']))
{
$product = node_load($nid);
$sku = $product->model;
}
else
{
$sku = $data['model'];
}

// Ask the current Inventory Manager if its ok to add this amount to the cart.

if(!uc_inventory_api_can_add($sku, $amount))
{
return array(
array(
'success' => FALSE,
'message' => t('Sorry, there is not enought in stock to add this to your cart.')
)
);
}
}

I wanna change it so that it will still allow you to add the items to cart but still show the message, but I want to change the message to "Sorry, there is not enough in stock your item will be add to your cart but placed in back order" There are 2 more parts that have to be change that effect sites with quantity adding in the catalog and quantity adding in the shopping cart adn I was trying to do the same thing allow the adding to negative stock and keep the message, but change to the message from:

'message' => t('Sorry, there is now %quantity \'%product_name\' left in stock.', array('%quantity' => $qty_in_stock, '%product_name' => $product->title))

to:

'message' => t('Sorry, there is now %quantity \'%product_name\' left in stock.', array('%quantity' => $qty_in_stock, '%product_name' => $product->title' your items will be placed in back order))

I have allot of ideas of changes to make to different module but it seems that people don't have the time to listen. Like i said before I willing to pay for the help to make these changes for every bodies sake.