Anyone know how I would go about disabling products on a sihlist that are out of stock? I have looked at out_of_stock_notification and it will display a message to the user once they have tried to add a product to their cart that is out of stock but I would rather disable the product or add to cart button so they cannot even attempt to add the product to their cart.

Comments

razorback’s picture

sihlist = wishlist

BigMike’s picture

Version: 6.x-1.1 » 6.x-1.x-dev

razorback,

I realize you posted this almost two years ago, but I am wondering if you found a solution to this yet. We are using UC Wish List 6.x-1.x-dev (from Feb 24, 2011) and from time to time we've had this problem where a product that was originally added to a wish list that has since become out of stock, is able to then be added to a new cart and be processed through checkout.

I've know this problem but have just been ignoring it. Today it came up again (it really hasn't happened all that often) and I decided I would search to see for a solution.

I am going to take a look at the module and see if I can figure out how to patch it to prevent this from happening.

I'll keep this updated-

Thanks
Mike

BigMike’s picture

Okay,

This was so damn easy I don't know why I never did this sooner.

File: uc_wishlist.pages.inc

Search for (at or near line 298):

    $element['addcart'] = array(
      '#type' => 'submit',
      '#name' => 'addcart-'. $item->wpid,
      '#value' => t('Add to cart'),
    );

Replace with:

    $stock = db_fetch_object(db_query("SELECT active, stock FROM {uc_product_stock} WHERE nid = '%d'", $item->nid));
    if ((($stock->active == 1) && ($stock->stock > 0)) || ($stock->active == 0)) 
      $stock = TRUE;
    else
      $stock = FALSE;

    if($stock)
      $element['addcart'] = array(
        '#type' => 'submit',
        '#name' => 'addcart-'. $item->wpid,
        '#value' => t('Add to cart'),
      );
    if(!$stock)
      $element['addcart'] = array(
        '#type' => '',
        '#name' => '',
        '#value' => t('Currently Out Of Stock'),
      );

Now uc_wishlist will replace the 'Add to cart' button with the text "Currently Out Of Stock" whenever the item is out of stock (as per /node/####/edit/stock) regardless of when the item was added to the user's Wish List. The moment the item is back in stock, either by disabling the Stock feature of the node or giving the node some positive stock level, the 'Add to cart' button returns.

BigMike

BigMike’s picture

Status: Active » Needs review
Anonymous’s picture

Hi all,
The #3 code also works fine.But the attached patch remove the Add to Wishlist button from the product that are Out of stock.Using this there is no need to use the #3 code.The attached patch provide the option to enable this at Admin Settings page.http://sitename.com/admin/store/settings/wishlist .You can also see the admin settings in the attached screenshot.

Anonymous’s picture

I have added some more changes in #5 patch. If the Stock module is not enabled then it does not provide the option on the admin page. Use the attached patch below rather than #5 patch.

tparc’s picture

As I'm not an expert at porting code to D7, I am wondering if the maintainer(s) are looking into patching this issue in that version. Also Tie in to Product Kits: https://drupal.org/node/1327562 .
Could be very useful.

jaykainthola’s picture

Hi,

I had some personal problem, due to this I was not able to work since last 2 months. So, I could not check the issue list. But, I will look into this issue list and will implement patches into module.

Thanks

naveenvalecha’s picture

HI jaykainthola,
if you are facing problems then you can also get the help of another developer by seeking co-maintainer of the module.I think by doing this the process will become fast.What do you think ?

jaykainthola’s picture

Hi naveenvalecha,

Thanks for your suggestion and If someone be interested into co-maintainer of this project, he will most welcome.

Thanks

naveenvalecha’s picture

Hi jaykainthola,
I am interested to help you to maintain this to make the process fast.what do you think ?

jaykainthola’s picture

Hi naveenvalecha,

I have provide permission to you. Please check.

Thanks

naveenvalecha’s picture

Hi jaykainthola,
I got the permission.Please let me know when you will be available on IRC to discuss the module to do list( if you have made) and other things.So that we can go further into this.

tparc’s picture

Issue summary: View changes

Hello, maintainers, I notice that there hasn't been much progress on some of these issues. Understandable if you are busy. Just wanted to follow up my request from #7 above if you find some time. Thanks

BigMike’s picture

nick_daffodil,

I just saw this and your reply with patch at #5.

"the attached patch remove the Add to Wishlist button from the product that are Out of stock."

Just because something is out of stock doesn't mean one no longer yearns for it. Why not keep the Add to Wishlist button available so that once the part does return to stock, they can simply push their Wishlist through and receive your product?

-BigMike

jaykainthola’s picture

nick_daffodil,

I am totally agree with BigMike. If a product is out of stock, then we need to allow user to add product in wishlist section. We need to prevent user to purchase product which is out of stock.

Thanks,
Jayendra Kumar

naveenvalecha’s picture

Hi Jayendra

I think there is two possiblities either not to show the Wishlist button OR Not to purchase product from wishlist.I think we should consider both cases before going to update on this issue.

Thanks
Naveen Valecha

jaykainthola’s picture

@naveenvalecha, we should user to prevent user to purchase product if its out of stock. If I like something, then I can add this into my wishlist so that when its will be in stock, I can purchase the product.

I have already updated the module with same concept.

Thanks,
Jayendra Kumar

tparc’s picture

Perhaps the best route would be to
1) disable the add to cart button on a user's wishlist page when the product is out of stock, and
2) give the administrator the option to allow/disallow users to add items to their wishlist if they're out of stock.
As websites' needs are different, it would be good to appease both needs.
3) Also Tie in to Product Kits: https://drupal.org/node/1327562 would be good to commit to D7. Will post there.
Thanks.

naveenvalecha’s picture

@jaykainthola
The way that @tparc suggested in #19 is good to implement.What do you think?

Thanks
Naveen Valecha

jaykainthola’s picture

@naveenvalecha

Yes, its good to implement. I will look into the same and will update the module accordingly.

BigMike’s picture

Good work people. My code from #3 satisfies tparc's condition (1). We've been using this alteration for more than a year without any issues.

Regards,
BigMike

jaykainthola’s picture

@BigMike,

Mostly patch is related to Drupal 6, so we can not commit patch into Drupal 7 version.

Thanks,
Jayendra Kumar

naveenvalecha’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Assigned: Unassigned » naveenvalecha

Hi Folks

I am taking this one.Will provide the patch soon for 7.

Thanks
Naveen Valecha

jaykainthola’s picture

Hi tparc,

I have implemented your suggestion.

@Naveen, I have already worked on the same. Thanks for considering this issue.

Thanks,
Jayendra kumar

jaykainthola’s picture

Assigned: naveenvalecha » Unassigned

Implement suggestion by tparc. We need to review this.

Thanks,
Jayendra Kumar

tparc’s picture

Thanks for implementing. There seems to be a problem where all items are disabled from being added to the wishlist when 'Allow users to add out of stock item into wishlist.' is unchecked. Can you duplicate?

tparc’s picture

Another issue found that prevents any items with attributes being added to the cart from the wishlist. This seems to be a major issue. Can it be looked into?

jaykainthola’s picture

@tparc, Thanks for sharing this. I will look into this and will update you as soon as possible.

Could you share an example of "There seems to be a problem where all items are disabled from being added to the wishlist when 'Allow users to add out of stock item into wishlist.' is unchecked.", so I have clear view of this.

jaykainthola’s picture

@tparc, I have checked and if any item has stock value, then item with attribute is being added to cart. If you are using any other thing, please let me know.

tparc’s picture

I apologize, I realized that this only affects items with UC Attribute Stock (https://drupal.org/project/ubercart_attribute_stock) enabled. This module allows a stock level for each product attribute. Is there any way to accommodate this? I'm not familiar with the inner workings of this module.
Thanks again.

jaykainthola’s picture

@tparc, I will look into this and will update you as soon as possible.

Thanks,

tparc’s picture

Hi jaykainthola, have you had a chance to look into this yet? Thanks.

jaykainthola’s picture

Hi Tprac,

I will update you soon.

Thanks,
Jayendra Kumar

jaykainthola’s picture

@Tprac,

I have checked the UC Attribute Stock and I found that stock level is not decreasing when we purchase the product. I think, there is still some issue in the module, so we need to wait some time to implement this module in Ubercart wishlist.

Thanks,
Jayendra Kumar

naveenvalecha’s picture

Assigned: Unassigned » jaykainthola

Updating the issue summary.
Need your opinion on this @Jayendar Kumar

Thanks
Naveen Valecha

berenddeboer’s picture

The following patch, against the dev version implements the right behaviour I think:

  • If you allow people to order out of stock of items, it prevents nothing.
  • If uc_stock module is not enabled, it prevents nothing.
  • If stock is not enabled for the product, or there is stock, it prevents nothing.

Only if the stock is less or equal to zero do we prevent the "Add to wishlist" button to be shown.

berenddeboer’s picture

Rerolled patch against head.

naveenvalecha’s picture

Assigning to myself will review it later today.

naveenvalecha’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch not applied successfully.Needs Reroll

naveenvalecha’s picture

Assigned: naveenvalecha » Unassigned
rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new6.96 KB

rerolling...

berenddeboer’s picture

Status: Needs review » Fixed

I think this has been committed right? I think we can close this. Have set status to fixed.

berenddeboer’s picture

Status: Fixed » Needs review

Oops, my mistake this patch hasn't been committed, was confused.

naveenvalecha’s picture

Assigned: Unassigned » jaykainthola

@jaykainthola,
Would U take this a look and Make this issue a final touch.

berenddeboer’s picture

Issue tags: -Needs reroll
StatusFileSize
new6.87 KB

Have rerolled patch.

berenddeboer’s picture

Slight change to patch so #2091331: Notify Admin Order Contains Wishlist Item can be applied more cleanly on top of this.

naveenvalecha’s picture

Thanks!
Applied the patch with minor nutpick and committed to dev branch.Also updated the documentation at several places.
Would you test it on local dev box with the latest branch.

naveenvalecha’s picture

Status: Needs review » Fixed
naveenvalecha’s picture

Commited f89843a & fixed.

  • naveenvalecha committed 843c4a0 on 7.x-1.x
    Issue #728550 by berenddeboer, rpayanm: Disable products on wishlist...

  • jaykainthola committed 695ab91 on
    Issue #728550 by razorback: Disable product on wishlist that are out of...
  • jaykainthola committed 51321ab on
    Issue #728550 by razorback: Implement suggestion by tparc
    
  • naveenvalecha committed 843c4a0 on
    Issue #728550 by berenddeboer, rpayanm: Disable products on wishlist...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.