News:

Support the VirtueMart project and become a member

Main Menu

Disable addtocart button per availability

Started by stawebnice, December 28, 2017, 10:59:09 AM

Previous topic - Next topic

stawebnice

Hi,

please is  there a way to disable addtocart button for selected availability? I have an eshop where stocks do not apply for all products, so using general config for 0 stock is not a solution. But there is an image availability vyprodano.jpg (sold out) for which I would need to disable add to cart and replace it by notify  button.


GJC Web Design

vyprodano.jpg  ?  applied as a custom field?

If so  .. detect if the field is present.. if so hide/replace the add to cart
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

Hi,
It's possible to write a little plugin to use a custom field to disable add to cart button(or other feature)

Milbo

Not sure, but I think you need only to enable one option. Ah yes "Stockhandling on product level ", it is directly above the radio list of the options "Action when a Product is Out of Stock"
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

stawebnice

Hi,

not as custom field, but as availability field - image.

People must be able to order other products with 0 stock that have different availability images (one week etc.) but this one availability means sold out - for lets say couple months, so he does not want to unpublish the product yet. But we want to allow them to fill in the Notify me form for this product.




GJC Web Design

then this is the way

QuoteIf so  .. detect if the field is present.. if so hide/replace the add to cart

check for the image name - probably do it in templates\xxxxxx\html\com_virtuemart\sublayouts\addtocartbar.php
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

Quote from: Milbo on December 29, 2017, 11:56:51 AM
Not sure, but I think you need only to enable one option. Ah yes "Stockhandling on product level ", it is directly above the radio list of the options "Action when a Product is Out of Stock"

Ehrm?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jjk

#7
I just assign a different product details page on which the AddToCart button is disabled to those products and add a 'sold out' text into the availability text field.

For this I've created a different sublayout which is a copy of 'addtocart.php' with the addtocart button disabled and named it 'noaddtocart.php'.

Then created a copy of ...\components\com_virtuemart\views\productdetails\tmpl\default.php and replaced
Quoteecho shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));
with
Quoteecho shopFunctionsF::renderVmSubLayout('noaddtocart',array('product'=>$this->product));
and stored that as 'not-available.php', which I can select as the Product Details Page.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Studio 42

JJK, this solution does not work on category view or modules .

jjk

Quote from: Studio 42 on January 02, 2018, 23:27:16 PM
JJK, this solution does not work on category view or modules .
True, but I don't have that problem, because I disabled the addtocart button in those (in order to force my customers to look at the full description before adding a product into the cart)
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations