• Resolved jagp2001

    (@jagp2001)


    Hi, I can′t find a way to do price field mandatory, how can I do it, thanks?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Thread Starter jagp2001

    (@jagp2001)

    Ok but if price is impossible to be required, how can I set in ZERO all ads that does not fill price?

    I need price because if user does not set price so in grid view all ads are showed on bad way.. please see now here: https://allubu.com/clasificados-categorias/

    Thanks.

    Thread Starter jagp2001

    (@jagp2001)

    Or maybe other solution is that if vendor does not put price, shwo a button that says Consult to vendor, please help me with a piece of code to to this, thanks.

    • This reply was modified 7 years ago by jagp2001.
    Plugin Author Greg Winiarski

    (@gwin)

    You should be able to disallow entering zero in the Price field by adding the below code in your theme functions.php file

    
    function no_leading_zero( $data ) {
        return ltrim( $data, "0" );
    }
    
    add_action( "init", "no_leading_zero_init" );
    
    function no_leading_zero_init() {
        adverts_form_add_filter("no_leading_zero", array(
            "callback" => "no_leading_zero"
        ));
    }
    
    add_filter( "adverts_form_load", "no_leading_zero_adverts_add" );
    function no_leading_zero_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_price" ) {
            $form["field"][$key]["filter"][] = array( "name" => "no_leading_zero" );
        }
      }
      return $form;
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to do price reqiuered on ad?’ is closed to new replies.