• Resolved mahwash

    (@mahwash)


    Please i heed your help, I want my users to be able to select their local currency to advertise their items.

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

    (@gwin)

    Currently, in WPAdverts it is only possible to have a single currency for a whole site, the currency you can define in wp-admin / Classifieds / Options / Core.

    If the currency you would like to use is not on the list you can add it as explained here https://github.com/simpliko/wpadverts-snippets/blob/master/add-currency/add-currency.php

    Thread Starter mahwash

    (@mahwash)

    Ok thanks

    Thread Starter mahwash

    (@mahwash)

    Hi Greg, thanks for that information, but i really want my target users to advertise in their own local currency.
    Please can you help me with the code that will create currencies in dropdown menu on the add adverts page?

    Thanks for your help.

    Plugin Author Greg Winiarski

    (@gwin)

    I am afraid this is not really possible right now, The best you can do is disable WPAdverts code which is responsible for formatting the currency so users will be able to enter any text in the Price field.

    Thread Starter mahwash

    (@mahwash)

    I think is a nice idea temporarily.

    Please can you show me how to disable it?

    Plugin Author Greg Winiarski

    (@gwin)

    You can do that by adding the code below to your theme functions.php file

    
    add_filter( "adverts_get_the_price", "disable_price_formatting", 10, 3);
    add_filter( "adverts_form_load", "disable_price_validation" );
    
    function disable_price_formatting( $formatted_price, $price, $post_id ) {
      return $price
    }
    
    function disable_price_validation( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_price" ) {
            $form["field"][$key]["class"] = "";
            $form["field"][$key]["filter"] = array();
        }
      }
      return $form;
    }
    
    Thread Starter mahwash

    (@mahwash)

    Hi Greg, the code is breaking the site, below is the error message.
    Parse error: syntax error, unexpected ‘}’ in /home/content/n3pnexwpnas02_data02/78/3730578/html/wp-content/themes/social-magazine/functions.php on line 194

    Plugin Author Greg Winiarski

    (@gwin)

    Sorry, there is a typo in my code, this should work fine

    
    add_filter( "adverts_get_the_price", "disable_price_formatting", 10, 3);
    add_filter( "adverts_form_load", "disable_price_validation" );
    
    function disable_price_formatting( $formatted_price, $price, $post_id ) {
      return $price;
    }
    
    function disable_price_validation( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == "adverts_price" ) {
            $form["field"][$key]["class"] = "";
            $form["field"][$key]["filter"] = array();
        }
      }
      return $form;
    }
    
    Plugin Author Greg Winiarski

    (@gwin)

    To have it working in wp-admin as well you will need additionally this line in disable_price_validation function

    
    $form["field"][$key]["attr"] = array( "id" => "adverts_price_x");
    
    Thread Starter mahwash

    (@mahwash)

    Thanks a million Greg, it works fine, cheers

    Thread Starter mahwash

    (@mahwash)

    Hi Greg, There is still a an issues with the above code. When i changed the currency symbol and clicked publish, it came up with the below error message. Thanks

    ning: number_format() expects parameter 1 to be double, string given in /home/content/n3pnexwpnas02_data02/78/3730578/html/wp-content/plugins/wpadverts/includes/functions.php on line 289

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, right now the only way to fix that is to disable notices and warnings on site, you can do that by opening file wp-config.php and adding there following line

    
    define("WP_DEBUG", false);
    
    Thread Starter mahwash

    (@mahwash)

    Hi Greg, that line of code exist there and is false.

    Plugin Author Greg Winiarski

    (@gwin)

    Try opening file wpadverts/includes/functions.php and replacing line 289

    
    $number = number_format( $price, $c['decimals'], $c['char_decimal'], $c['char_thousand']);
    

    with

    
    $number = number_format( (float)$price, $c['decimals'], $c['char_decimal'], $c['char_thousand']);
    
    Thread Starter mahwash

    (@mahwash)

    Hi Greg, it works, Thanks for your support.

    I’m looking forward to the next update, I hope that most of these issues will be resold,

    Great job, great support.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Enable users to use local currency to advertise’ is closed to new replies.