I want to add custom text field on product details page Where user enter some text . Which text will be shown on cart and checkout page. I have added the text field on product but it is not saving .Please guide me what things i am missing?

 function my_module_form_alter(&$form, &$form_state, $form_id)
   if($form_id == 'uc_product_add_to_cart_form_2')

     $form['additional_guests'] = array(
      '#type' => 'textfield',
      '#title' => t("Additional Guest Names"),          


How can i save this custom field and getting on cart/checkout page?

  • Use Attributes and set up a Textfield attribute on your product. – anonymous Jun 21 '19 at 19:09

The uc_attributes module, which has been part of Ubercart for 12 years, was specifically designed to handle this situation.

Enable the uc_attributes module. Edit your product, then go to the "Attributes" tab and add a "textfield" type attribute to your product. Your customer will then be able to add text to the purchased product. This textfield will be displayed in the cart, on the checkout page, on the review order page, and in the admin/user view of the completed order.

In short, the correct way to do this is to "Use Attributes and set up a Textfield attribute on your product" as I stated in my previous answer (which was erroneously turned into a "comment" by some unknown user).

The Ubercart project page at https://www.drupal.org/project/ubercart gives links to detailed information about how to do this. Specifically, see: https://www.drupal.org/docs/7/modules/ubercart/all-about-products/product-attributes-and-options and the video tutorial at https://www.youtube.com/watch?v=fVDOqI7Gge4

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.