-
AuthorPosts
-
December 21, 2016 at 5:23 pm #727165
Hi, I would like to add a dropbox menu to the checkout page. It should say: “how did you find about us?” and give some options to choose from as well as to write his own answer. I haven’t find a way to add this anywhere in the template. Please help
December 21, 2016 at 5:36 pm #727186Hey comelen!
Can you please post a mockup/screenshot showing the changes you would like to make so we can make sure that we are on the same page?
You can upload your screenshots on imgur.com or Dropbox public folder and post the links here.Best regards,
YigitDecember 21, 2016 at 6:00 pm #727204Thank you very much for your quick respond!
Here is the link to the screenshot:https://www.dropbox.com/s/f3hledn8809ktq3/checkout.jpg?dl=0
I hope it’s possible and not very difficult to do.
Will appreciate your help
December 27, 2016 at 10:04 pm #728302Hi,
Please add following code to Functions.php file in Appearance > Editor
add_action( 'woocommerce_after_order_notes', 'custom_referer_field' ); function custom_referer_field( $checkout ) { echo '<div id="checkout-referer-field"><h2>' . __('Heading') . '</h2>'; woocommerce_form_field( 'custom_referer', array( 'type' => 'text', 'class' => array('custom-referer form-row-wide'), 'label' => __('How did you know about us?'), 'placeholder' => __('Referer'), 'required' => true, ), $checkout->get_value( 'custom_referer' )); echo '</div>'; } /** * Process the checkout */ add_action('woocommerce_checkout_process', 'custom_referer_field_process'); function custom_referer_field_process() { // if the field is set, if not then show an error message. if ( ! $_POST['custom_referer'] ) wc_add_notice( __( 'Please enter referer.' ), 'error' ); } /** * Update the order meta with field value */ add_action( 'woocommerce_checkout_update_order_meta', 'custom_referer_field_process_order_meta' ); function custom_referer_field_process_order_meta( $order_id ) { if ( ! empty( $_POST['custom_referer'] ) ) { update_post_meta( $order_id, 'Referer', sanitize_text_field( $_POST['custom_referer'] ) ); } }
Best regards,
Yigit -
AuthorPosts
- You must be logged in to reply to this topic.