VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: roman5527 on April 21, 2021, 15:08:09 PM

Title: Custom field on category page
Post by: roman5527 on April 21, 2021, 15:08:09 PM
Hi, i need show custom field from position addtocart on category page but only one from all on position addtocart.

Is it possible show custom field based example ID ?? or other identification ?

Can you help me with code ??

Many Thanks
Title: Re: Custom field on category page
Post by: Studio 42 on April 21, 2021, 22:33:19 PM
Virtuemart have no context option, so you need to code yourself a solution.
You can check for eg, if you are in category or not and check the customfield_id of the custom fields.
Title: Re: Custom field on category page
Post by: pinochico on April 22, 2021, 09:21:49 AM
QuoteHi, i need show custom field from position addtocart on category page but only one from all on position addtocart.

I don't understand, can you write more information?.
- one customfield (add to cart) in category page for all products in one place (it is sound like catproduct plugin) or one for every product on category page (== 6 products == 6 customfields add to cart) ?

Title: Re: Custom field on category page
Post by: roman5527 on April 22, 2021, 13:43:42 PM
I have two custom fields for products in the addtocart position.
I show both in the product detail.
But I only want to see one of them on the categories page.
It cannot be solved by assigning one of them to another position because these are the inputs of the basket so it must be in the addtocart position.

Therefore, my question is whether it is possible to display a custom field from the addtocart position based on an ID or other identifier.

well thank you
Title: Re: Custom field on category page
Post by: pinochico on April 22, 2021, 16:59:49 PM
Yes,

in PHP you can use IF/ELSE custom code
and then show this customfield in category view
Title: Re: Custom field on category page
Post by: roman5527 on April 23, 2021, 13:46:35 PM
Ok  . please can you please show me some sample code? How to do it ?

thanks
Title: Re: Custom field on category page
Post by: Studio 42 on April 24, 2021, 11:44:03 AM
But perhaps a better solution is to use another positionand not addtocart ?
Why you have field to show in category in the cart position ?