VirtueMart Forum

VirtueMart 2 + 3 => Installation, Migration & Upgrade => Topic started by: stawebnice on December 28, 2017, 10:59:09 am

Title: Disable addtocart button per availability
Post by: stawebnice on December 28, 2017, 10:59:09 am
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.

Title: Re: Disable addtocart button per availability
Post by: GJC Web Design on December 28, 2017, 11:29:46 am
vyprodano.jpg  ?  applied as a custom field?

If so  .. detect if the field is present.. if so hide/replace the add to cart
Title: Re: Disable addtocart button per availability
Post by: Studio 42 on December 28, 2017, 16:43:20 pm
Hi,
It's possible to write a little plugin to use a custom field to disable add to cart button(or other feature)
Title: Re: Disable addtocart button per availability
Post by: 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"
Title: Re: Disable addtocart button per availability
Post by: stawebnice on December 29, 2017, 19:19:37 pm
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.



Title: Re: Disable addtocart button per availability
Post by: GJC Web Design on December 30, 2017, 11:47:25 am
then this is the way

Quote
If 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
Title: Re: Disable addtocart button per availability
Post by: Milbo on January 02, 2018, 11:17:53 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?
Title: Re: Disable addtocart button per availability
Post by: jjk on January 02, 2018, 23:13:04 pm
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
Quote
echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$this->product));
with
Quote
echo shopFunctionsF::renderVmSubLayout('noaddtocart',array('product'=>$this->product));
and stored that as 'not-available.php', which I can select as the Product Details Page.
Title: Re: Disable addtocart button per availability
Post by: Studio 42 on January 02, 2018, 23:27:16 pm
JJK, this solution does not work on category view or modules .
Title: Re: Disable addtocart button per availability
Post by: jjk on January 02, 2018, 23:34:14 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)