Different number for each shipment
-
Good morning, it is possible to do this with every sending
do you increase the number entered in a numeric field? Thank you
-
Hi @quadcore
I hope you are doing well today.
To be on the same page when it comes to your request please let us know does your main goal is:
A) have a number field that will be dynamic, and after each submission, the number will rise and will be not editable.
B) In the email body or in the email title notifications have an increasing number as a custom ID/number of orders?
Kind Regards,
Krishi, thanks for the reply. Yes, point 1 interests me. a numeric field that increases with each submission. Thank you
Hi again @quadcore
I pinged our SLS Team so that they can see that will be possible in this case. We will post an update here as soon as more information is available.
Kind Regards,
KrisHi @quadcore
This snippet should help. Form ID and field ID should be managed in the code:
add_action( 'forminator_before_form_render', 'wpmudev_number_field_form_check', 10, 5 ); function wpmudev_number_field_form_check( $id, $form_type, $post_id, $form_fields, $form_settings ) { if ( 1609 == $id ) { // Please change the form ID. add_action( 'forminator_field_number_markup', 'wpmudev_number_field_increment_auto', 10, 5 ); } } function wpmudev_number_field_increment_auto( $html, $id, $required, $placeholder, $value ) { if ( false !== strpos($id, 'number-1') ) { // Please change the number field ID. global $wpdb; $table_meta = $wpdb->prefix . 'frmt_form_entry_meta'; $table_entry = $wpdb->prefix . 'frmt_form_entry'; $num_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $table_meta as m LEFT JOIN $table_entry as e ON m.entry_id = e.entry_id WHERE m.meta_key = %s AND e.form_id = %d LIMIT 1;", 'number-1', 1609 ) ); $html = str_replace( 'value="'.$value.'"', 'value="'.$value.'" readonly', $html ); if ( ! empty( $num_count ) ) { $num_count = $num_count + 1; $html = str_replace( 'value="'.$value.'"', 'value="'.$num_count.'"', $html ); } } return $html; }where 1609 should be your form ID, and number-1 is your number field ID.
He is a guide on how to install mu-plugin:
https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-pluginsKind Regards,
KrisHi @quadcore,
I hope the provided workaround was helpful.
It’s been a while since we heard from you, so I’ll go ahead and mark this thread as resolved. If you have any additional questions or need further assistance, please feel free to let us know.
Kind Regards,
Nebu JohnGood morning, no it’s too complicated for me, thanks
The topic ‘Different number for each shipment’ is closed to new replies.