• Resolved ETIC-Studio

    (@nicolas-leclerc)


    Hello,
    I wanted to use a “hidden” field in the product page to be able to retrieve the value and modify my final price using “add_action( ‘woocommerce_before_calculate_totals’)….”.
    The problem, to access the input I have a name like “<input name=’wccpf_gO6HM9L6H0QW’ ….>
    This does not use the name of the field that we put in the settings.
    And since we can’t put a “class” on it!….
    What would be the best method to access this field in “woocommerce_before_calculate_totals” please?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ETIC-Studio

    (@nicolas-leclerc)

    I forgot,
    in your example you put this:

    “Product Field’s Raw Output
    <!– Hidden field doesn’t have any wrapper – since hidden anyway –>
    <input type=”hidden” name=”test_product_hidden” value=”” /> “

    Plugin Contributor Sark

    (@sarkware)

    Hi, from version 4.X.X we decided to generate unique key for each field, when they being created. The intention is to avoid naming collision between fields, which is the case for the prior versions.

    There is one way, you can supply your own keys for fields when they are created.

    function override_field_id($_newId, $_groupId, $_fieldType = null) {
        /* Update the field id here */
        if ($_fieldType == "hidden") {
            $_newId = "Your own id";
        }
        return $_newId;
    }
    add_filter("wcff_new_field_id", "override_field_id", 10, 3);
    • This reply was modified 3 years, 12 months ago by Sark.
    Plugin Contributor Sark

    (@sarkware)

    This option is added with the version 4.0.7, pls update and let me know if it worked.

    To update the key, click on the field key, it will turned into a text box, where you can enter a new key once done press Enter key.

    Finally click on the Update button.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Name input not very “Friendly”’ is closed to new replies.