Using the Marketplace Lite Plugin, how do I make the phone number on the order form a required field

I am using the marketpress eCommerce plugin, and the client would like the phone number to be a required field on the order form. The phone number is already a field, however it is not required. Is the anyway I can change that?

  • Vaughan
    • Support/SLS MockingJay


    it's not quite so simple.

    you would need to custom code it. i think in marketpress-includes/template-functions.php

    you would need to create an error filter & add an asterisk.

    search for

    $content .= '<td align="right">'.__('Phone Number:', 'mp').'</td><td>';
          $content .= '<input size="20" name="phone" type="text" value="'.esc_attr($phone).'" /></td>';

    add an * before the 1st </td>


    $content .= '<td align="right">'.__('Phone Number:', 'mp').'*</td><td>';
          $content .= '<input size="20" name="phone" type="text" value="'.esc_attr($phone).'" /></td>';

    now you need to create a new filter.

    $content .= apply_filters( 'mp_checkout_error_phone', '' );

    so we have

    $content .= '<td align="right">'.__('Phone Number:', 'mp').'*</td><td>';
          $content .= apply_filters( 'mp_checkout_error_phone', '' );
          $content .= '<input size="20" name="phone" type="text" value="'.esc_attr($phone).'" /></td>';

    i have no idea if that's all it needs, i haven't tested. but imo phone number shouldn't be a required field, not everyone wants to give their numbers out & some people don't have a phone. it could turn away buyers. though there's nothing stopping them entering 123456789 as their number, so i don't think making it required is effective.

    hope this helps

  • Thomas Edgell
    • The Incredible Code Injector

    Many thanks Vaughan. I will present that to the client and go from there. I am not an expert programmer.. and really do not want to blow up the site by accident.. I have many hours logged on this project.

    Thank you for you time,

    Best Regards,
    Tracie Edgell

  • Nathan Onn
    • Design Lord, Child of Thor

    There is a better way in doing this. Just insert the following codes into your functions.php file.

    add_action( 'mp_shipping_process', 'mp_require_phone' );
    function mp_require_phone() {
    global $mp;
    if (empty($_POST['phone']))
    $mp->cart_checkout_error( __('Please enter your Phone number.', 'mp'), 'phone');
  • John Kirker
    • WPMU DEV Initiate

    I love my WPMU membership but so many of the plugins seem half-baked and rarely upgraded with features once the base is established. I don't see much evolution on things and that's a shame...

    Regarding MarketPress, why isn't there an option to select which fields are and are not mandatory? When it comes to the phone number. If someone is ordering something, why would they be concerned about providing their phone number?

    • Vaughan
      • Support/SLS MockingJay

      Hi John,

      Whilst I can't speak for everyone, many people are concerned with being forced to provide information that is not actually necessary in order to buy an item.

      I personally do not like having to add my phone number in order to make purchases, especially when that phone number is not an actual requirement in order to buy an item. Why do you need my phone number to buy a t-shirt or a new hoover etc?

      Many don't like it because of spamtext messages and phonecalls from telesales and marketing companies where they have purchased user details databases from other companies etc. Many just want to buy their items & then be left in peace without being called or texted on the phone every week with new offers or enticing offers trying to get them to buy further items.

      So unless your sales actually require you to contact the buyer for whatever reason, then there is no need whatsoever to require a person to enter their phone number. On the occasions i have seen forms where a phone number is required, i tend to just enter 12345678.

      As I say, I can't speak for everyone, but that's my own opinion on why I don't like it.

      Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.