Avatar of Robert Granlund
Robert Granlund
Flag for United States of America

asked on 

Variable Custom Fields in WooCommerce Checkout

I have a special case and I don't know where to start.  I have a WooCommerce store that sells a book review service. People submit their book and it is professionally reviewed.  They can submit more than one book at a time.  However, at checkout I need to capture certain information; Author Name, Publishing Date, Description.  I am using WooCommerce from fields  for this.

  $saved_book_title = $current_user->book_title;
   woocommerce_form_field( 'book_title', array(        
      'type' => 'text',        
      'class' => array( 'form-row-first' ),        
      'label' => 'Book Title',        
      'placeholder' => 'book title',        
      'required' => true,        
      'default' =>  $saved_book_title,        
   ), $checkout->get_value( 'book_title' ) );

However, they can purchase more than 1 review.  So if they purchase 3 reviews for three different books, how do I capture the same woocommerce_form_fields, three times in a row?

 I would need to capture the author Name, Publishing Date and Description 3 different times.  If they submitted 8 books, I would need to capture it 8 times.  

Do I loop through and include the function three times?  But that would give me three of the exact same ID's.  HELP


Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon