VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: capewellmj on July 10, 2015, 18:41:52 PM

Title: Remove add-to-cart from category page when custom fields present
Post by: capewellmj on July 10, 2015, 18:41:52 PM
Hello

I have mentioned this before as a suggestion but i'd like to report it now as a bug. When a product has custom fields that the customer must choose on the product page. It is causing us problems with VM3 because it continues to show the add-to-cart on the category pages and allows the customer to bypass choosing any options.

I feel this is a bug if they can purchase products without choosing parameters.

A simple fix would be to disable the add-to-cart button on category pages when custom fields are present. This is how VM2 handled custom fields.

Great work btw, a lot more versatility for programmers (so they tell me) and for users with custom fields on VM3.

Thank you.

Martin
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: jenkinhill on July 10, 2015, 20:35:20 PM
VM3 does show customs on the category view page as well as the product details page when using the default template system. eg see http://demo.virtuemart.net/wear

If you do not use the default VM templates then it is possible that your overrides need updating to show the customs.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: capewellmj on July 10, 2015, 22:10:19 PM
Hi Jenkinhill

I do not want the custom fields to show on the category pages. I deliberately disabled" Show product customfields in browse views".

I guess a better way of making my request is to say that when "Show product customfields in browse views" is disabled, the add-to-cart should also be disabled from the category pages.

Thank you,

Martin

Title: Re: Remove add-to-cart from category page when custom fields present
Post by: AH on July 11, 2015, 10:20:55 AM
IMHO -  A "disable add to cart and cart customfields" in category browse  - would be beneficial - as there is no point in displaying add to cart customfields if you do not also display the add to cart button.

Maybe someone can enlighten you as to whether the "display customfields in caetgory browse" only affects cart customfields
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Studio 42 on July 11, 2015, 19:13:50 PM
Hi,
I have the same problem, with the default "add to cart" in category view.

It's a pain to fith in the cart customfields and have a nice render.
I forced in the plugin to not render the customfields, because this can have 10 line.
But the other problem is when you display product modules in your product details page.
The plugin trigger is the same then you cannot disable the customfield in the modules, or you have to do a hock with javascript to hide this fields and cha,ge the add to cart to choose a variant

The only solution i know is to add multiple function, or adding a boolean to know the render zone.

for eg. trigger in plugin

plgVmOnDisplayProductFEVM3
plgVmOnDisplayModuleFEVM3
plgVmOnDisplayProductInCategoryFEVM3

The simpliest is to add a context value as Joomla do:

public function onContentPrepare($context, &$row, $params, $page = 0)
{
$allowed_contexts = array('com_content.category', 'com_content.article', 'com_content.featured');

if (!in_array($context, $allowed_contexts))
{
return true;
}
........
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on July 14, 2015, 10:50:56 AM
Quote from: Hutson on July 11, 2015, 10:20:55 AM
IMHO -  A "disable add to cart and cart customfields" in category browse  - would be beneficial - as there is no point in displaying add to cart customfields if you do not also display the add to cart button.

Maybe someone can enlighten you as to whether the "display customfields in caetgory browse" only affects cart customfields

Do you sell only product variants? There are a lot shops they dont use any variants.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Margriet on October 07, 2015, 11:07:54 AM
Maybe this illustrates the problem. Customer can order T-shirt without selecting size.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on November 04, 2015, 12:22:35 PM
For me that looks solved in vm3.0.11.4.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Margriet on November 04, 2015, 12:26:27 PM
Hi Max,
Unfortunately not. To make sure, just installed a fresh Joomla 3.4.5 with fresh VM 3.0.11.4 with only demo data and this is the result:
http://yndidev.tk/vm3/wear
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Studio 42 on November 04, 2015, 22:49:10 PM
Problem is same in product page. If you manipulate the HTML form and js, you can add to cart without any variants/options.
This is stupid most of case, but can be a problem in some case.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on November 06, 2015, 10:50:33 AM
Quote from: Margriet on October 07, 2015, 11:07:54 AM
Maybe this illustrates the problem. Customer can order T-shirt without selecting size.


Now I got the problem with it, when the customfields are disabled,.... ahhh. Hmm you should not disable em that way, then. When you disable them by config, the customfields are not processed.

In this case you must use a template override, for the sublayout products
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Margriet on November 06, 2015, 11:59:10 AM
Then maybe I don't understand why this option is available in configuration. In my opinion it should then be enabled by default and leave it to website developer to make an override (or simply hide custom fields with css).
And when option is available it should work in a way that if custom fields are present but not shown the add to cart button is not available but Product Details button is.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on November 06, 2015, 15:07:40 PM
The option is there to prevent the load of it. It changes the way to load the data. It is an option for shops having performance issues. Not a GUI thing, actually.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: IJack on November 06, 2015, 16:33:14 PM
If there is an option to show/hide customfields in category view why not to add one more option to show/hide add to cart button in category view?
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Studio 42 on November 06, 2015, 17:51:52 PM
HI,
Quote from: IJack on November 06, 2015, 16:33:14 PM
If there is an option to show/hide customfields in category view why not to add one more option to show/hide add to cart button in category view?
Some commercial template have this option.
Another  simple way is to manually remove the code calling the addtocart render
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: servlet on November 06, 2015, 19:49:45 PM
I have the same problem...
It will be nice if there is ON/OFF function in config section. In this way all will be happy - someone want to use this option someone no. For some shops it is no good to bypass product view.
CSS hide - it is no good - you have queries I think?!? you will hide them but they will be loaded.
It will be nice if this is a category option - you may decide to use this option for chosen categories.... (may be it will be nice there is both option global ON/OFF and category ON/OFF, this will spend time if you dont want to use this option globally or if you want to use it for specific categories)
Give to user choice... give them way to use brain. ;)

I ask for this option in VM 1.0.... long time ago...
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on November 06, 2015, 21:13:50 PM
not hiding via css, it is an override of the products.php in the sublayout, and you just need to omit one line, the display of customfields. But they are processed then.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: servlet on November 06, 2015, 22:03:06 PM
I am using override ... I think for other users ... I think for the future... this is needed option...

(this is not template customizing for pink or black add to cart button ;) )
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: lindapowers on November 09, 2015, 15:45:36 PM
Another mystery is the layout depending on the position chosen for the custom fields: ontop, normal, addtocart, onbot etc
Some of this render in category view others don't. Some documentation in this aspect would be appreciated.

We already use an override to hide the "chose a variant button" so meanwhile youll have to do the same for this case I guess.

Quote from: Margriet on October 07, 2015, 11:07:54 AM
Maybe this illustrates the problem. Customer can order T-shirt without selecting size.


Exactly thats a case where you require the option, for us would be: customer can order product without selecting "optional" size (fruits) which is good... but yeah could happen the case where we require them to actually select a custom field. I understand the request here but pls understand the way is managed currently is good for some shops like ours so yeah.. option needed.

I don't know how it works with string custom fields but with generic child variants we put 0 stock and no price to the parent and therefore only the childs (dropwdown) are selectable.

Regards
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Milbo on November 10, 2015, 14:05:26 PM
Quote from: lindapowers on November 09, 2015, 15:45:36 PM
Another mystery is the layout depending on the position chosen for the custom fields: ontop, normal, addtocart, onbot etc

ontop,addtocart which are "input"
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: websmith on January 08, 2016, 04:46:57 AM
Has there been a fix for this as im having the same issue. Add to Cart displays in category view and when clicked it goes straight to cart bypassing all custom field options.
This is a big problem for my project. Can anyone offer a solution for this? Thank you in advance.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: lindapowers on January 08, 2016, 09:34:42 AM
Quote from: websmith on January 08, 2016, 04:46:57 AM
Has there been a fix for this as im having the same issue. Add to Cart displays in category view and when clicked it goes straight to cart bypassing all custom field options.
This is a big problem for my project. Can anyone offer a solution for this? Thank you in advance.

I don't know how you have set custom fields but this statement is not correct.

If you set custom fields of type string in a dropdown list the first option you set will be added to the product so I don't see where the custom fields are being bypassed.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Margriet on January 08, 2016, 10:11:22 AM
@lindapowers: see my screenshots in post #6. This has not changed since!
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: lindapowers on January 08, 2016, 15:53:18 PM
Quote from: Margriet on January 08, 2016, 10:11:22 AM
@lindapowers: see my screenshots in post #6. This has not changed since!

If you are using generic childs why don't you set the parent with 0 price, that way they are forced to choose one of the variants.

Thats why I didn't notice the issue, cause we use parents with no price and not chooseable.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: websmith on January 08, 2016, 16:27:49 PM
Quote from: lindapowers on January 08, 2016, 09:34:42 AM
Quote from: websmith on January 08, 2016, 04:46:57 AM
Has there been a fix for this as im having the same issue. Add to Cart displays in category view and when clicked it goes straight to cart bypassing all custom field options.
This is a big problem for my project. Can anyone offer a solution for this? Thank you in advance.

I don't know how you have set custom fields but this statement is not correct.

If you set custom fields of type string in a dropdown list the first option you set will be added to the product so I don't see where the custom fields are being bypassed.

Ok, for arguments sake, if you have sizes S, M and L, and colors R, W and B, if it simply picks the first line string it will still be wrong 2/3 of the time.  There should be a much easier way to remove the add to cart button from category layout so the customer is forced to choose all the variants or options available from the product details page.

Title: Re: Remove add-to-cart from category page when custom fields present
Post by: jjk on January 08, 2016, 20:05:39 PM
A simple method to remove the 'Add to Cart' button from the category views is to edit the file yourdomain\components\com_virtuemart\sublayouts\products.php. Comment out the display of the 'Add to Cart' button by adding '//' at the positions shown below (lines 108 and 109 in VM 3.0.12) to look like this:
<div class="vm3pr-<?php// echo $rowsHeight[$row]['customfields'] ?>"> <?php
//echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row])); ?>

Then save the file with a different filename into the same folder, for example 'products_less-cat-cart-btn.php'. Note that the filename has to begin with 'products_' in order to be recognized as a new sublayout. Leave the original file intact! Afterwards you can select that file from the dropdown list in VM 'Configuration' > 'Templates' tab > 'Sublayouts for products in category'.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Arno Millenaar on January 27, 2016, 10:59:33 AM
Quote from: Studio 42 on November 06, 2015, 17:51:52 PM
HI,
Quote from: IJack on November 06, 2015, 16:33:14 PM
If there is an option to show/hide customfields in category view why not to add one more option to show/hide add to cart button in category view?
Some commercial template have this option.
Another  simple way is to manually remove the code calling the addtocart render

Thanks for the provided solution.  Struggled several hours to find a solution.  Your suggestions works perfect !
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Tentaurus on January 29, 2016, 08:50:38 AM
Quote from: IJack on November 06, 2015, 16:33:14 PM
If there is an option to show/hide customfields in category view why not to add one more option to show/hide add to cart button in category view?

My opinion, too! To disable the add to cart should be an option in VM.
Title: Re: Remove add-to-cart from category page when custom fields present
Post by: Studio 42 on January 29, 2016, 10:52:59 AM
It"s not only a render problem, but when you have many cart customfields, this can be very slower as VM2, that don't included this option ! This can be some secondes, only for 20 products