VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: gba on December 08, 2020, 15:47:58 PM

Title: How to give a custom field a separate title for each product?
Post by: gba on December 08, 2020, 15:47:58 PM
Hello all!

How can I give a customfield a separate title for each product?
Sure, I could create a new copy of the customfield for each product and add it to the product then.
But that seems to me not to be very reasonable.
Isn't there any way to differently configure the title of one and the same customfield with each product?

Thank you very much in advance for any useful hint!

Kind regards,
Gerald
Title: Re: How to give a custom field a separate title for each product?
Post by: Jörgen on December 09, 2020, 10:49:59 AM
This is just an idea, turn off the display of title for the product and add a textfield before this customfield, there you can change the text as You please.

Jörgen @ Kreativ Fotografi
Title: Re: How to give a custom field a separate title for each product?
Post by: Studio 42 on December 09, 2020, 12:30:56 PM
A solution can be to generate the tittle with the product ID or name , but this need some PHP knowledge.
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 09, 2020, 15:42:52 PM
Quote from: Studio 42 on December 09, 2020, 12:30:56 PM
A solution can be to generate the tittle with the product ID or name , but this need some PHP knowledge.
Hm ... seems to be too complicated for the shop admin.
Thank you, though!
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 09, 2020, 15:44:35 PM
Quote from: Jörgen on December 09, 2020, 10:49:59 AM
This is just an idea, turn off the display of title for the product and add a textfield before this customfield, there you can change the text as You please.
Thank you for your idea.
I created a new custom field of type 'String'.
Then I added it to the product's custom fields and entered a text.
In frontend then a selectbox is displayed with that text as an option.
What did I do wrong?
Title: Re: How to give a custom field a separate title for each product?
Post by: Jörgen on December 09, 2020, 17:06:27 PM
Go through the custom field settings. The are maybe not obvious, but with som trial and error you Will get it.

Jörgen
Title: Re: How to give a custom field a separate title for each product?
Post by: Studio 42 on December 10, 2020, 11:34:29 AM
If you see a select box, it's because you have set it as an input or cart custom field
Title: Re: How to give a custom field a separate title for each product?
Post by: jenkinhill on December 10, 2020, 13:38:04 PM
This is what I use for a text instruction on one client site:

(https://i.ibb.co/rsJTtDJ/text-custom.jpg) (https://ibb.co/M6LWhFL)
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 10, 2020, 17:04:56 PM
Thank you very much for taking time to send me that screenshot.
I configured the custom field according that, except the setting 'Cart attribute' - this I set to 'Yes' to have it rendered in the cart, too.
But now I am still having the problem, that custom fields of type Y are being rendered after fields of type E in the cart.
This makes that solution approach useless.

The most flexible solution would be this new feature in the product backend, custom fields tab:  #featurerequest
Instead of just displaying the configured title (see now.jpg attached), display a textbox containing the title as default value (see new.jpg attached).
Then the shop admin could decide to leave the default title or set an individual one for that product.

Any other idea?
Title: Re: How to give a custom field a separate title for each product?
Post by: Jörgen on December 10, 2020, 23:07:48 PM
You know that You can change the order of customfields with drag and drop, yes ?

Jörgen
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 11, 2020, 09:42:52 AM
Yes, I know and did that.
And it works in product view.
But in the cart the Y fields actually are not being rendered at the place, where they are in the product backend.
Also the setting 'Show Title' seems to be ignored: The title is rendered within the same span as the textaread content, right before it.
Seems to be a bit weird ...
Title: Re: How to give a custom field a separate title for each product?
Post by: AH on December 11, 2020, 09:57:12 AM
You can always create your own customfield plugin if the core one does not suit your needs


And then you can create your own template to render as you want
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 11, 2020, 10:05:58 AM
I am using third party custom field plugins, which are constantly being maintained.
Everytime cloning them to have an editable title seems to be not that reasonable to me.

I attached the settings I made for the "title field" (see customfield.jpg).
I also attached a screenshot of the cart output, where I noted the order in the backend (see cart.jpg).
Title: Re: How to give a custom field a separate title for each product?
Post by: GJC Web Design on December 11, 2020, 11:09:33 AM
how about

<span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo vmText::_ ($field->custom_title.$product->virtuemart_product_id) ?></strong></span>

CUSTOMFIELD_TITLE22="title for pid 22"
CUSTOMFIELD_TITLE23="title for pid 23"

etc etc
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on December 16, 2020, 18:30:24 PM
Hi all!

Thank you again for your suggestions.

I gave the additional text field(s) before the concerning custom field(s) a try.
But it turned out, that it is not enough for us to just display an additional text field.
We need the title in the object of the respective custom field for further data processing.

The idea with concatenating the product id looks nice, too.
But actually we don't want to create a language override for every needed custom field in every product.

And cloning third party custom field plugins and maintaining the clones is way too expensive.

Therefore I am coming back to my idea:
The most flexible solution would be this new feature in the product backend, custom fields tab:
Instead of just displaying the configured title, display a textbox containing the title as default value.
Then the shop admin could decide to leave the default title or set an individual one for that product.

Unfortunately Milbo told me, that he is not interested in that feature.
From his point of view this would cost too much performance.
So does anyone, please, have any other/better idea to enable the shop admin to easily decide to leave the default custom field title or set an individual title for any product, where this is necessary?

I am very grateful for your help!

Kind regards,
Gerald
Title: Re: How to give a custom field a separate title for each product?
Post by: gba on October 14, 2021, 12:03:27 PM
Your help still is very much appreciated :)