• Resolved asky09

    (@asky09)


    Hello,

    how can I change the price in the product information to a mandatory item?

    • This topic was modified 5 years, 3 months ago by asky09.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    you can make the price field required by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "adverts_form_load_11115" );
    function adverts_form_load_11115( $form ) {
        if( $form['name'] != "advert" ) {
            return $form;
        }
        foreach( $form["field"] as $key => $field ) {
            if( $field["name"] != "adverts_price" ) {
                continue;
            }
            adverts_form_add_filter("no_leading_zero", array(
                "callback" => "no_leading_zero"
            ));
            $form["field"][$key]["filter"][] = array( "name" => "no_leading_zero" );
            $form["field"][$key]["validator"] = array( array( "name" => "is_required" ) );
        }
        return $form;
    }
    function no_leading_zero( $data ) {
        return ltrim( $data, "0" );
    }
    

    or by using the Custom Fields extension.

    Thread Starter asky09

    (@asky09)

    perfect thank you very much!
    You are my hero ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change price to a mandatory item’ is closed to new replies.