Author Topic: Custom Field types - which one to use when  (Read 717 times)

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Custom Field types - which one to use when
« on: January 13, 2023, 09:02:41 am »
I am using VM 4 and I need to create a few products where each product has the same three customization possibilities - EBOOK, PRINTED BOOK, and BOTH. The customer must select exactly one of these three options and the price needs to be updated according to their selection.

From what I read, I understand that I need to create a Custom Field with three possible values to achieve this but while creating a custom field, I see 16 possible custom field types and I am totally lost as to which type do I really need. I tried to find documentation that explains which custom field type is meant for what purpose but I could not find any. All I found was this page: http://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_product_customfields

Can someone please provide some pointers?

 

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28541
  • Always on vacation
    • Jenkin Hill Internet
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart 4.0.14 10805  J 3.10.11 PHP 8.0.27

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #2 on: January 13, 2023, 12:02:16 pm »
Thanks for responding. I checked out the links but none of them is applicable in the situation that I described.

I just need the same 3 options for all products and the price adjustments for each option is the same for all products.

Further, the Generic Child variant demo page at http://demo.virtuemart.net/product-variants/generic-child-cart-variant-detail doesn't work. When a variant is selected, the page shows the loading icon and never loads.

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #3 on: January 13, 2023, 12:11:14 pm »
I tried the String type :
With this, I have to configure each product individually. I have to add three options with prices to each product. Further, it lets me add the product to the cart even without any option being selected.

Then I tried String, is a list type:
With this, the benefit is that I don't have to create the options for each product. But then there is no way to specify a price for each of those options.


I am stuck. Please help.

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1512
Re: Custom Field types - which one to use when
« Reply #4 on: January 13, 2023, 12:36:24 pm »
You can set a price beside each value to update the price but yes you need to assign the custom fields to every product.
Also the native/built-in custom fields cannot be set to be required. In other words the field can be left empty or with the default selection.

If you want to have a required/mandatory check, you can use a 3rd party plugin like Custom Fields For All. This plugin will also give you more features like additional display types.

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4684
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #6 on: January 13, 2023, 12:52:36 pm »
You can set a price beside each value to update the price but yes you need to assign the custom fields to every product.

Thanks for responding. I am not sure I understood you correctly. Are you talking about custom field type of String ?

If I select YES for the "Is a list" option for a custom field of type String, I am able to specify the list of values separated with semicolon, such as: EBOOK;PRINTED BOOK;BOTH. This goes in the Default Value field, right? Where can I specify the price for each option? I don't see any place to put prices.

Also the native/built-in custom fields cannot be set to be required. In other words the field can be left empty or with the default selection.
I created a new custom field of type String with name Book Type. How can I enforce that that a selection for this field is made?

I will check out the plugin your mentioned.

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #7 on: January 13, 2023, 13:16:57 pm »
I created a custom field type of String, named BOOK TYPE with Cart Attribute set to NoCart Input set to Yes, and Is a list? set to No.

Now, I go to the product config page and add multiple custom fields of type "BOOK TYPE" with different values, each with a different price EBook, Printed, Both. All these values show up in the product page in a drop down named BOOK TYPE and prices are shown as +5, +5, +10 for each option. This is good. This is exactly what I want.

But it has two issues:

1. I have to create these options in every product, which is too tedious and a management hassle (in case, an option needs some change).

2. These options are not shown for the products on Category list page (where all products are listed). Moreover, the Add to cart button on this page adds the product to the cart with the base price. Further, when I view the cart, it shows the product with all the options (instead of just one). This is totally messed up.


Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4684
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Custom Field types - which one to use when
« Reply #8 on: January 13, 2023, 23:58:38 pm »
If you want use standard string, then use the cloning system after you created your main product
Another solution is to use a parent product, so all children inherit from parent




jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28541
  • Always on vacation
    • Jenkin Hill Internet
Re: Custom Field types - which one to use when
« Reply #9 on: January 14, 2023, 11:12:54 am »
You can use template overrides to remove your problems with the Category list page
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart 4.0.14 10805  J 3.10.11 PHP 8.0.27

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10744
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: Custom Field types - which one to use when
« Reply #10 on: January 14, 2023, 11:52:15 am »
Quote
I am using VM 4
version exactly?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #11 on: January 17, 2023, 11:37:04 am »
VirtueMart 4.0.12 10777

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #12 on: January 17, 2023, 12:00:18 pm »
I think I may have to give up on virtuemart at together.
It may handle several complicated things but the whole thing is so freaking complicate that I don't know how people use it specially when there is no documentation. On top of that, there doesn't seem to be any way to achieve a simple thing.  I have spent so much time on it trying to figure out how it works but, honestly, I think it sucks.

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1512
Re: Custom Field types - which one to use when
« Reply #13 on: January 17, 2023, 13:02:24 pm »
Here is how you add price to a custom field value, into the product


The custom field should have the "Cart Attribute" and "Cart Input" settings enabled

annpaul

  • Beginner
  • *
  • Posts: 23
  • A beginner
Re: Custom Field types - which one to use when
« Reply #14 on: January 17, 2023, 15:00:39 pm »
Yes, I understand that and I did that already. It worked but has two issues that I highlighted above. I am not finding a way around those issues.
Quote
I created a custom field type of String, named BOOK TYPE with Cart Attribute set to No,  Cart Input set to Yes, and Is a list? set to No.

Now, I go to the product config page and add multiple custom fields of type "BOOK TYPE" with different values, each with a different price EBook, Printed, Both. All these values show up in the product page in a drop down named BOOK TYPE and prices are shown as +5, +5, +10 for each option. This is good. This is exactly what I want.

But it has two issues:

1. I have to create these options in every product, which is too tedious and a management hassle (in case, an option needs some change).

2. These options are not shown for the products on Category list page (where all products are listed). Moreover, the Add to cart button on this page adds the product to the cart with the base price. Further, when I view the cart, it shows the product with all the options (instead of just one). This is totally messed up.