Title: Multiple Fields
Last modified: August 31, 2016

---

# Multiple Fields

 *  Resolved [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/multiple-fields/)
 * hello I have a few questions-
    1) can you add multiple fields? 2) if so, is there
   an sample script for multiple fields I can download? I see the sample script 
   but that is only for a single field. Thank you
 * [https://wordpress.org/plugins/offers-for-woocommerce/](https://wordpress.org/plugins/offers-for-woocommerce/)

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

 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6996896)
 * Yes, you would just follow that same procedure to add as many fields as you want
   within the hook function you’re using.
 * If you want to show me what you have and where exactly you’re getting stuck I
   can try to help more.
 *  Thread Starter [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6996908)
 * great and thanks for response. this is what i am working on —
 *     ```
       add_action('make_offer_form_before_submit_button', 'add_custom_field_make_offer_form', 10);
       add_action('make_offer_after_save_form_data', 'save_custom_field_make_offer_form', 10, 2);
       add_action('make_offer_after_buyer_meta_display', 'display_custom_field_buyer_section');
       add_action('make_offer_email_display_custom_field_after_buyer_contact_details', 'display_custom_field_after_buyer_contact_details', 10, 1);
   
       function add_custom_field_make_offer_form() {
           ?>
           <div class="woocommerce-make-offer-form-section">
               <label for="offer_postcode"><?php echo __('Postcode / Zip', 'offers-for-woocommerce'); ?></label>
               <br><input type="text" value="" required="required" name="offer_postcode">
                </div>
                <div class="woocommerce-make-offer-form-section">
               <label for="offer_size"><?php echo __('Size', 'offers-for-woocommerce'); ?></label>
               <br><select required="required" name="offer_size">
       					<option value="">Select an option...</option>
       					<option value="Small">Smalll</option>
                           <option value="Medium">Medium</option>
                           <option value="Large">Large</option>
                           <option value="X-Large">X-Large</option>
       				</select>
                     </div>
           <?php
       }
   
       function save_custom_field_make_offer_form($post_id, $post) {
       	if (isset($post['offer_postcode']) && !empty($post['offer_postcode'])) {
               add_post_meta($post_id, 'offer_postcode', $post['offer_postcode']);
           }
       	if (isset($post['offer_size']) && !empty($post['offer_size'])) {
               add_post_meta($post_id, 'offer_size', $post['offer_size']);
           }
       }
   
       function display_custom_field_buyer_section($post_id) {
           $offer_postcode = get_post_meta($post_id, 'offer_postcode', true);
           ?>
           <li><span><?php echo __('Postcode / Zip:', 'offers-for-woocommerce'); ?>&nbsp;</span>
               <?php echo (isset($offer_postcode)) ?
                   stripslashes($offer_postcode) : __('Missing Meta Value', 'offers-for-woocommerce'); ?>
           </li>
           <?php
   
       	$offer_size = get_post_meta($post_id, 'offer_size', true);
           ?>
           <li><span><?php echo __('Size', 'offers-for-woocommerce'); ?>&nbsp;</span>
               <?php echo (isset($offer_size)) ?
                   stripslashes($offer_size) : __('Missing Meta Value', 'offers-for-woocommerce'); ?>
           </li>
           <?php
       }
   
       function display_custom_field_after_buyer_contact_details($post_id) {
           $offer_postcode = get_post_meta($post_id, 'offer_postcode', true);
           echo (isset($offer_postcode) && !empty($offer_postcode)) ?
               '<br /><strong>' . __('Postcode / Zip:', 'offers-for-woocommerce') . '&nbsp;</strong>' . stripslashes($offer_postcode) : '';
   
       	 $offer_size = get_post_meta($post_id, 'offer_size', true);
           echo (isset($offer_size) && !empty($offer_size)) ?
               '<br /><strong>' . __('Size', 'offers-for-woocommerce') . '&nbsp;</strong>' . stripslashes($offer_size) : '';
       }
       ```
   
 *  Thread Starter [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6996912)
 * great- thanks for your quick response
 *     ```
       <?php
       add_action('make_offer_form_before_submit_button', 'add_custom_field_make_offer_form', 10);
       add_action('make_offer_after_save_form_data', 'save_custom_field_make_offer_form', 10, 2);
       add_action('make_offer_after_buyer_meta_display', 'display_custom_field_buyer_section');
       add_action('make_offer_email_display_custom_field_after_buyer_contact_details', 'display_custom_field_after_buyer_contact_details', 10, 1);
       function add_custom_field_make_offer_form() {
           ?>
           <div class="woocommerce-make-offer-form-section">
               <label for="offer_postcode"><?php echo __('Postcode / Zip', 'offers-for-woocommerce'); ?></label>
               <br><input type="text" value="" required name="offer_postcode">
                </div>
                <div class="woocommerce-make-offer-form-section">
               <label for="offer_size"><?php echo __('Size', 'offers-for-woocommerce'); ?></label>
               <br><select required="required" name="offer_size">
       					<option value="">Select an option...</option>
       					<option value="Small">Smalll</option>
                           <option value="Medium">Medium</option>
                           <option value="Large">Large</option>
                           <option value="X-Large">X-Large</option>
       				</select>
                     </div>
           <?php
       }
   
       function save_custom_field_make_offer_form($post_id, $post) {
       	if (isset($post['offer_postcode']) && !empty($post['offer_postcode'])) {
               add_post_meta($post_id, 'offer_postcode', $post['offer_postcode']);
           }
       	if (isset($post['offer_size']) && !empty($post['offer_size'])) {
               add_post_meta($post_id, 'offer_size', $post['offer_size']);
           }
       }
   
       function display_custom_field_buyer_section($post_id) {
           $offer_postcode = get_post_meta($post_id, 'offer_postcode', true);
           ?>
           <li><span><?php echo __('Postcode / Zip:', 'offers-for-woocommerce'); ?>&nbsp;</span>
               <?php echo (isset($offer_postcode)) ?
                   stripslashes($offer_postcode) : __('Missing Meta Value', 'offers-for-woocommerce'); ?>
           </li>
           <?php
   
       	$offer_size = get_post_meta($post_id, 'offer_size', true);
           ?>
           <li><span><?php echo __('Size', 'offers-for-woocommerce'); ?>&nbsp;</span>
               <?php echo (isset($offer_size)) ?
                   stripslashes($offer_size) : __('Missing Meta Value', 'offers-for-woocommerce'); ?>
           </li>
           <?php
       }
   
       function display_custom_field_after_buyer_contact_details($post_id) {
           $offer_postcode = get_post_meta($post_id, 'offer_postcode', true);
           echo (isset($offer_postcode) && !empty($offer_postcode)) ?
               '<br /><strong>' . __('Postcode / Zip:', 'offers-for-woocommerce') . '&nbsp;</strong>' . stripslashes($offer_postcode) : '';
   
       	 $offer_size = get_post_meta($post_id, 'offer_size', true);
           echo (isset($offer_size) && !empty($offer_size)) ?
               '<br /><strong>' . __('Size', 'offers-for-woocommerce') . '&nbsp;</strong>' . stripslashes($offer_size) : '';
       }
       ```
   
 *  Thread Starter [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997183)
 * hello did you review what I had? I just need to know how to add multiple fields.
   thank you
 *  [kcppdevelopers](https://wordpress.org/support/users/kcppdevelopers/)
 * (@kcppdevelopers)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997193)
 * Yes, we have reviewed your sample code.
 * If you want to add multiple fields then you need to follow the same procedure
   as defined in your sample code.
 * I can modify your script for you if you can give fields name you want to add.
 * Please let us know if you anything not clear.
 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997194)
 * As [@kcppdevelopers](https://wordpress.org/support/users/kcppdevelopers/) mentioned,
   you just need to repeat the process you’ve done for the additional fields you
   want to add. Did you try that already? Is there a specific place you’re getting
   stuck?
 *  Thread Starter [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997200)
 * Hello. so the code I wrote was right? Hmmm it was not working for me during testing…
   strange. maybe there is some other glitch with it not related to what i wrote?
 * I tested the above code and it says successfully sent but it does not send or
   save in wp-admin area. I then tested it with just the single zip code field (
   exactly as you had it) and it worked perfect with just that so i figured I made
   a mistake adding the additional fields.
 * if you can confirm my code is right then I know there is a mistake elsewhere 
   and I will need to debug. thank you for your help!!!!
 *  [kcppdevelopers](https://wordpress.org/support/users/kcppdevelopers/)
 * (@kcppdevelopers)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997203)
 * Yes, I confirm that the code is perfect which you have sent.
 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997204)
 * [@redvon69](https://wordpress.org/support/users/redvon69/), we’ve tested your
   exact snippet in our test server and it’s working as expected. If it’s not working
   on your server there must be something else conflicting with it. We could help
   you troubleshoot that, but you’ll need to [submit an order for premium support](https://www.angelleye.com/product/premium-support/)
   in order for us to do that.
 *  Thread Starter [redvon69](https://wordpress.org/support/users/redvon69/)
 * (@redvon69)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997214)
 * ok I figured out why it was was not working. I had a typo in the code in another
   part of the functions.
 * thank you very much for your help. it is a great plugin and support is great.
   i will leave good review. thanks!
 *  Plugin Contributor [angelleye](https://wordpress.org/support/users/angelleye/)
 * (@angelleye)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997215)
 * Glad you got it worked out!

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

The topic ‘Multiple Fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/offers-for-woocommerce_edefee.svg)
 * [Offers for WooCommerce](https://wordpress.org/plugins/offers-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/offers-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/offers-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/offers-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/offers-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/offers-for-woocommerce/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [angelleye](https://wordpress.org/support/users/angelleye/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-fields/#post-6997215)
 * Status: resolved