Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Require Customer Input only when 'Add to Cart' is clicked.

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Tweaks › Require Customer Input only when 'Add to Cart' is clicked.

Tagged: customer input, required

  • This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by gbkovacs.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • December 2, 2014 at 9:44 pm #11863
    gbkovacs
    Member

    I have just purchased the eStore and am using it for a non-profit educational conference website. We offer classes at our annual conference and I need to collect the student’s names when someone pays for a class. I have the ‘Customer Input’ field setup and found a post on how to modify the js file to require the field.

    Can I require or make mandatory the Collect Customer Input field?

    It works fine, the only issue is that with variations on the product (i.e. Time – AM, PM, Classtype etc.) every time you click a dropdown you get the required information dialog. Is there a way to have this code execute only when the ‘Add to Cart’ Button is pushed? I am not a php or java programmer (or a web programmer for that matter) but do have some coding background.

    Thanks.

    December 3, 2014 at 4:26 am #67162
    admin
    Keymaster

    In that case I would recommend that you undo the previous tweak. Then add something like the following to the top of that JavaScript file:

    jQuery(document).ready(function($) {

    $(‘.eStore-button-form’).submit(function(e) {

    //check if the custom input field has a value. If not show an error and return false

    });

    });

    If you post a link to the page where you are using it, I should be able to give you a complete example.

    December 3, 2014 at 2:12 pm #67163
    gbkovacs
    Member

    Wonderful, I have never used jquery. Thanks for your help.

    [http://fabaconference.org/conference-registration/]

    December 4, 2014 at 4:03 am #67164
    admin
    Keymaster

    Add the following block of code at the beginning of the “lib/eStore_read_form.js” file and that will do the job.

    jQuery(document).ready(function($) {
    $('.eStore-button-form').on('submit', function() {
    var $thisbuttonform = $(this);
    var custom_input = $thisbuttonform.find('.eStore_collect_input').val();
    if(!custom_input.trim()){
    alert('Please enter a value in the custom input field');
    return false;
    }
    });
    });

    Alternatively, you can use the following JS code (this one listens for the “click” event on the add to cart button instead of “submit”:

    jQuery(document).ready( function($) {
    $('.eStore-button-form .eStore_add_to_cart_button').on('click', function() {
    var addcartinput = $(this);
    var buttonform = addcartinput.closest('form');//Get the parent form for this input
    var custom_input = buttonform.find('.eStore_collect_input').val();
    if(!custom_input.trim()){
    alert('Please enter a value in the custom input field');
    return false;
    }
    });
    });

    December 4, 2014 at 2:15 pm #67165
    gbkovacs
    Member

    Simple clean code, worked wonderfully. Thank you.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ