Author Topic: How to Display Out of Stock Items But Disable Add to Cart  (Read 1104 times)

snowgoose

  • Beginner
  • *
  • Posts: 5
  • A beginner
How to Display Out of Stock Items But Disable Add to Cart
« on: April 29, 2019, 20:55:37 pm »
Hi,
I have come across lots of similar questions to this on the forum, but no answer!

I am trying to set up a shop selling unique items. For example, shoulder bags that are hand made so although there may be 20 shoulder bags, every one is different. I have set up "shoulder bags" as a category and then each unit shoulder bag is a separate item so therefore only 1 in stock of each item.
I would like to show the items that are sold so people can see the sort of things that have been sold, but of course I don't want people to be able to order another one becasue the item is unique and there will never be another one. Ideally, the picture should say "SOLD" underneath and the "ADD TO CART" button should be disabled or not there.
I can make the item say "SOLD OUT" but then people can keep ordering more (why does this happen as I have set the stock level to 1 for every item?). The only way I can see to prevent ordering an infinite number of 1 item is to make it invisible when sold out. Is this really the only way??

Thanks
Dave
VM3.2.15 Joomla 3.9.5

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2473
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #1 on: April 29, 2019, 21:40:24 pm »
Hello

In back end You find under VM configuration -> shop front end a setting stock control for out of stock items. Choose the right version for Your need.

Jörgen @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

snowgoose

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #2 on: April 29, 2019, 23:29:20 pm »
Hi Jorgen,
That is where I was looking, but there is no setting to do what I want. All settings that still show an out-of-stock product also allow you to buy it (even though it is out of stock...I find this very strange....how can anyone buy something that is out of stock???). The only setting that stops anyone buying an out-of-stock item is the one that makes the item disappear. I don't want it to disappear...I just want it to still display the item and say "out of stock".

Is this possible please?

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2473
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #3 on: April 30, 2019, 08:41:29 am »
The only explanation is that You are using a custom template with outdated code. The stock VM core works as expected, You can not buy out of stock items and out of stock items will be marked sold or similar.

Jörgen @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

snowgoose

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #4 on: April 30, 2019, 09:49:18 am »
Hi,
That shouldn't be the reason. I am using the default Protostar template which comes with Joomla and I am using the latest Joomla and VM releases.
The options I have are the following:
  • Product out of stock are orderable, no special action (Clearly that is meant to allow ordering of out of stock items)
  • Do not display product (That will stop ordering but it makes the product disappear)
  • Do not display product, if child products also out of stock (not relevant as I am not using child products)
  • Displays 'notify Me' instead of 'Add to Cart' button (I don't wan tthis because customers will think they can get more stock added)
  • Products out of stock are orderable, and the filed 'availability' below is displayed (Here I can write a custom message such as 'sold out' but it still allows people to place an order.
So please, which one of the above should I use to meet my requirements? None meet them. Is there another way to do this? I cannot understand why the option to make an item unorderable with 'sold out' written over it. This is available on all other shops I have used.

Thank you
Dave

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2473
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #5 on: April 30, 2019, 10:04:08 am »
OK, then You have to do a override.

templates/your-template/html/sublayouts/addtocartbar.php

Copy the original file from components/com_virtuemart...../sublayouts/addtocartbar.php, if you do not have any override yet.

Lookup the piece of code that shows the notify button. Comment out or replace with whatever you like.
Code: [Select]
echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id)
regards

Jörgen
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9245
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #6 on: May 03, 2019, 12:17:53 pm »
Displays 'notify Me' instead of 'Add to Cart' button (I don't wan this because customers will think they can get more stock added) and replace the Notify button with a sold out etc label
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2473
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #7 on: May 03, 2019, 12:45:18 pm »
Killing the link to the button obviously.

Jörgen
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

snowgoose

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #8 on: May 03, 2019, 17:33:19 pm »
Sorry for the late reply, but I had problems understanding the override. However, I realised that the path you gave me was slightly wrong. Should have been templates/your-template/html/com_virtuemart/sublayouts/addtocartbar.php (I should have realised but I haven't done any overrides before).

For those interested, this is what I did:
In CONFIGURATION...SHOPFRONT...ACTION WHEN A PRODUCT IS OUT OF STOCK choose "Displays notify me instead of add to cart button"
I then went to Joomla menu EXTENSIONS...LANGUAGE(S)...OVERRIDES. In the LANGUAGE CONSTANT box I put COM_VIRTUEMART_CART_NOTIFY (this is the constant that currently says "Notify Me" when the item is out of stock). I then put in the TEXT box "Sorry, this item is sold".
Now when an item is out of stock instead of "notify me" it says "sorry, this item is out of stock".
This is almost good enough, but the words are still a clickable link which I don't want. So I copied addtocartbar.php as Jorgen kindly showed me in this post. I then removed the code that created a link and left just the text.
REPLACE: <a href="<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=productdetails&layout=notify&virtuemart_product_id=' . $product->virtuemart_product_id); ?>" class="notify"><?php echo vmText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?></a>
WITH:   <?php echo vmText::_ ('COM_VIRTUEMART_CART_NOTIFY') ?>So now when an item is out of stock, it can be displayed and labelled as out of stock and not orderable.

Maybe this will help someone.

Many thanks to Jorgen for pointing me in the right direction.
Dave

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4072
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #9 on: May 03, 2019, 17:34:49 pm »
With the new "Discontinued" option, does it not work ?

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3551
  • using Matomo instead of Google Analytics
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #10 on: May 03, 2019, 22:47:09 pm »
Perhaps this helps: https://forum.virtuemart.net/index.php?topic=139178.msg488840#msg488840
I'm still using it to display sold out art prints without the 'Add to cart' button. However it might work only because I've also disabled the 'Add to cart' button in the category views. Example: https://kiekebusch.com/en/automobile-art/1955-mille-miglia-detail

(I think the 'Discontinued' option is meant for products which a shop still has in stock, but which are being produced anymore. It doesn't disable the 'Add to cart' view.)
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

snowgoose

  • Beginner
  • *
  • Posts: 5
  • A beginner
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #11 on: May 03, 2019, 23:13:07 pm »
@Studio42....the discontinued function does not do what I want.

@JJK, yes I saw your solution when searching for a solution for me. I hadn't considered disabling add to cart for category view but I can see now that it would work well for me. Nice website btw.

The method I am using works well so I'll stick with it, but thanks all for your ideas.

Dave

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9245
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: How to Display Out of Stock Items But Disable Add to Cart
« Reply #12 on: May 04, 2019, 10:26:03 am »
Quote
With the new "Discontinued" option, does it not work ?

seems to only mark them as such in the DB - I guess the idea is then to use this in your templates
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation