Support » Plugin: Registrations for WooCommerce » Adding custom checkout fields

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Allyson Souza

    (@allysonsouza)

    Hi @ejwerk,

    I’m sorry, at the moment the method that creates the checkout fields is inflexible, without hooks for customization, what is really bad. I added this enhancement issue to GitHub and expects to make it as soon as possible.

    For now, what I think you could do is give a look at WC_Registrations_Checkout class, remove the default actions that creates the fields, copy and make changes on it in your plugin or theme functions.php.

    Could you give me a file name and line number of where I’m going to find this?

    Plugin Author Allyson Souza

    (@allysonsouza)

    You can find the code in classes/class-wc-registrations-checkout.php.

    There’s various methods in that class to add properly the fields, their validations and display in order meta. In this entry at WooCommerce documentation you can find all the steps to add custom checkout fields, you can follow their examples and so remove the actions defined in that plugin class and create your own fields in your theme/plugin: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    I hope it helps.

    We’re busy planning a project that might use this plugin, do you have a slightly more concrete ETA on including this? (cowroker wants to know if he has to plan for the manual edit or if he can wait for you to include this in an update)

    Plugin Author Allyson Souza

    (@allysonsouza)

    Hi @ejwerk,

    Sorry but at the moment I can’t promisse anything, but I expect to do this in two or three weeks. If you find a good solution adding a hook into the plugin, please, make a PR in GitHub.

    I can’t seem to wrap my head around adding custom fields ( I’m probably missing a step somewhere )
    how is the update coming along?
    otherwise would it be possible to get an example of how to add a field?

    Plugin Author Allyson Souza

    (@allysonsouza)

    Hi @ejwerk,

    I’m working on it, today I’ve added a hook to make possible to add new fields for each participant in checkout, now I’m working on how to make possible to display that fields too in admin Order view.

    With this modifications will be like this to add new fields:

    function registrations_display_my_custom_fields( $checkout, $current_participant ) {
    	woocommerce_form_field( 'participant_nickname_' . $current_participant , array(
    		'type'          => 'text',
    		'class'         => array('participant-nickname form-row-wide'),
    		'label'         => __( 'Nickname', 'registrations-for-woocommerce' ),
    		'placeholder'   => __( '', 'registrations-for-woocommerce'),
    	), $checkout->get_value( 'participant_nickname_' . $current_participant )
    	);
    }
    
    add_action( 'registrations_display_participant_fields', 'registrations_display_my_custom_fields', 10, 2 );

    I think in the next week I’ll release the 1.1.0 with that improvements.

    (Now to make your own code, removing plugin actions could be hard to acomplish, so if you can wait, I’ll work on it to release as soon as possible)

    I’m being asked to fill in a timeplan for a site that might use this, is it possible for this to be done within the next 2 weeks?

    otherwise can you explain to me how and where to implement this hook to add fields
    and give an example of how to use this hook?
    I hope to hear from you soon

    Plugin Author Allyson Souza

    (@allysonsouza)

    Hi @ejwerk

    Sorry for the late reply, we’re releasing the version 1.0.7 right now, and in this version I’ve added some hooks to make easyer to add new checkout fields for each participant.

    There’s a lot of steps to do (and I think there’s nothing to do about that), I tried to document the steps in that GitHub Wiki page (We are still creating the full plugin documentation): https://github.com/HasteDesign/Registrations-for-WooCommerce/wiki/Custom-checkout-fields

    I hope that finally helps you.
    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Adding custom checkout fields’ is closed to new replies.