Select Field – Wc Fields Factory

Product Field

Insert a select fields on the product page.

Option Description
Options Use the Option Factory (Located at the Right Side) to create options for select. for manual creation see the below explanation.
This option is used to generate the select option, each select option will contains Value attribute (which is not visible to User) and Label attribute which is visible to the users.
So basically we need two things to create a single select option, Value and Label, Value represent the Value attribute of the select option and Label represent the visual caption of the select option.
Here we represent a single option with “|” delimiter, for more than one option, delimite with new line.

         red|Red     <!-- Option 1 -->
         green|Green     <!-- Option 2 -->
         blue|Blue     <!-- Option 3 -->
         
Default Options Default Options for this select, All the options created for this select will be displayed here on real time – (These options will be used incase If user hadn’t chosen any).
Required Make this Select field mandatory – user cannot perform Add To Cart operation without choosing any option.
Message Message that has to be displayed when validation failed for this select field (When the Required Option is Set).
Visibility Whether this select option value (Chosen by the user) has to be displayed on the Cart & Check Page.
Note: Regardless of this option this fields value will be added as Order Meta (Unless you configured not so).
Order Item Meta Whether to add this field’s value (Chosen by the user) as Order Item Meta.
Logged in Users Only Make this field available only for the Registered Users only (They must have to be logged in).
Target Roles Make this field available only for the users that have the selected roles. Available to all, if you haven’t selected any
Editable Make this field’s value editable on Cart Page – (incase If user has chosen the wrong value, he can correct it on the cart page itself, no need to go back to product page).
Note: this is only for the Cart page not for the Checkout Page.
Cloneable Exclude this field from cloning (Works only if Cloning option is enabled from the Settings Page).
Field Class Use this option to add a custom css class to this field for your own styling purpose (added to each radio buttons).
Product Field Raw Output
<table class="wccpf_fields_table ">
	<tbody>
		<tr>
			<!-- Label section starts here -->
			<td class="wccpf_label">
				<label for="test_select_field">Test Select Field</label>
			</td>
			<!-- Label section ends here -->
						
			<td class="wccpf_value">
				<!-- Actual field starts here -->
				<select class="wccpf-field " name="test_select_field" wccpf-type="select" wccpf-pattern="mandatory" wccpf-mandatory="no" data-cloneable="yes">
					<option value="red">Red</option>
					<option value="blue">Blue</option>
				</select>
				<!-- Actual field ends here -->
				
				<!-- Validation message section -->
				<span class="wccpf-validation-message">This field can't be left un chosen</span>
			</td>			
		</tr>
	</tbody>
</table>

Admin Field

All the above options available for the Admin Field as well, along with those there are some specific options related to only Admin Fields.

Option Description
Show on Product Page Show this field on Front end Product page as well.
Read Only Whether to show this field as Read Only Field (applicable only on Front End Product Page).
Value or Field Show the value that is chosen on this Admin Field instead as the Field itself. Whatever the option, Store Admin chosen for this field on the back end will be displayed on the Front end Product Page.
Tips Whether to show the tip icon in the back end.
Description Tool-tip message, when admin user click on the Tips Icon.
Admin Field Raw Output (on Product Page)
<p class="form-field test_admin_select_field">
	<!-- Label for the Select field -->
	<label for="test_admin_select">Test Admin Select</label>
	
	<!-- Actual field starts here -->
	<select class="wccaf-field " name="test_admin_select" wccaf-type="select" wccaf-pattern="mandatory" wccaf-mandatory="no">
		<option value="red">Red</option>
		<option value="blue">Blue</option>
	</select>
	<!-- Actual field ends here -->
	
	<!-- Validation message section -->
	<span class="wccaf-validation-message">This field can't be left un chosen</span>
</p>
Admin Field Raw Output (on Product Category Create Page)
<div class="form-field">
    <!-- Label for the Radio Button Group -->
    <label for="test_admin_select">Test Admin Radio</label>
     
    <!-- Actual field starts here -->
	<select class="wccaf-field " name="test_admin_select" wccaf-type="select" wccaf-pattern="mandatory" wccaf-mandatory="no">
		<option value="red">Red</option>
		<option value="blue">Blue</option>
	</select>
	<!-- Actual field ends here -->
     
    <!-- Validation message -->
    <span class="wccaf-validation-message">This field can't be Empty</span>
</div>
Admin Field Raw Output (on Product Category Edit Page)
<tr class="form-field">
    <!-- Admin Edit Category field's label starts here -->
    <th scope="row" valign="top">
        <label for="test_admin_select">Test Admin Radio</label>
    </th>
    <!-- Admin Edit Category field's label ends here -->
         
    <td>
        <!-- Actual field starts here -->
		<select class="wccaf-field " name="test_admin_select" wccaf-type="select" wccaf-pattern="mandatory" wccaf-mandatory="no">
			<option value="red">Red</option>
			<option value="blue">Blue</option>
		</select>
		<!-- Actual field ends here -->
         
        <!-- Validation message -->
        <span class="wccaf-validation-message">This field can't be Empty</span>
    </td> 
</tr>

Leave a Reply to rubi Cancel reply

Your email address will not be published.

 

12 Comment(s)

  1. abdo May 14, 2022

    hello Good Work guys i was looking for that you’re the best plugin ; pleas if someone can help me i want to hide value&label from my product page because i cant affor them now just i want to hide them ..?

    1. Saravana Kumar K May 17, 2022

      Hi, you can just edit the Select Field’s Option using the admin view. Just remove the entry and you are good to go, later if needed you can re insert it.
      If you don’t want to remove, you can just disabvle the option using JavaScript, once the page is loaded.

  2. Paolo Piselli March 24, 2018

    In the Cart page, you usually get the VALUE of the Select options: if you would prefere to get the LABEL, you can apply this little modification to the file \wp-content\plugins\wc-fields-factory\includes\wcff-cart-data.php

    Substitute around line 259 with this if:

    /* To visualize the Label instead of the Value for the Select options */
    if (isset($_field[“choices”])) {
    $this->wccpf_items[] = array(“name” => $cif_data[“field_key”], “value” => find_label($cif_data[“field_val”], $_field[“choices”]));
    } else {
    $this->wccpf_items[] = array(“name” => $cif_data[“field_key”], “value” => $cif_data[“field_val”]);
    }

    Add this little function at the end of the file:

    function find_label($_val, $_choices) {
    $_choi = explode(“;”,$_choices);
    foreach ($_choi as $_couple) {
    $_temp = explode(“|”,$_couple);
    if ( $_temp[0] == $_val ) {
    return $_temp[1];
    }
    }
    return $_val;
    }

  3. Windows Chrome December 18, 2017

    Why can’t I use my scrollbar on this page in Windows Google Chrome? That’s kind of annoying / un-user-friendly…

    1. Saravana Kumar K December 21, 2017

      Yes, that is in Browsers hand, we cannot override select box scroll, unless we use a custom scroll bar widget.

  4. Antanas December 10, 2017

    What is the use up “required” option if in any case at least the default option will be selected… there should be a placeholder, that would be selected by default and would not count as a valid selection

    1. Saravana Kumar K December 10, 2017

      I agree, I will add an additional config for placeholder.

      1. rubi December 17, 2017

        Please add a placeholder option.
        I can’t use the dropdown because I don’t want any of the options as default.

        Thank you

        1. rubi December 17, 2017

          OK. I found a way to do it.
          Just leave the first value empty. like that:

          |please choose
          Red|Red
          Blue|Blue

          1. Saravana Kumar K December 17, 2017

            Hi, from version 2.0.5 there is separate option for Placeholder.

  5. Sabine Kächele December 8, 2017

    Since the last update, fields factory no longer works.

    1. Saravana Kumar K December 8, 2017

      What is the issue.? can you post your product page link here.? if you have a chance to look into your php error_log you might get a idea that why its happening.