• I am using the Woocommerce module to integrate with your plugin. For some reason, on the ad placement page, user can’t select one product, but only 3 at once, that is, all existing ones. At the same time, in the Packages section in the console, it is generally empty. Please help me set this up correctly.

Viewing 15 replies - 61 through 75 (of 83 total)
  • Thread Starter Triptikon

    (@triptikon)

    How to do that?

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,

    i suppose you just need to create a page with the same blocks but in a different language, can’t tell exactly as this probably depends on the plugin you are using.

    Note that most likely each of the pages will display the same list of ads just the interface will be in a different language.

    Thread Starter Triptikon

    (@triptikon)

    But I want the English version of the site to display on this page only those ads, that were created using the appropriate form

    Plugin Author Greg Winiarski

    (@gwin)

    This would require some custom programming as we do not have integration with any of the multi-lingual plugins to do it automatically.

    For example, if you are using the Custom Fields extension and each version of the site has it’s own form scheme then you could use something like this to filter the ads by the form scheme used (this should be equal to filtering by language used when posting)

    add_filter( "adverts_list_query", "filter_by_form_scheme", 10, 2 );
    function filter_by_form_scheme( $args, $params ) {
        $page_to_fs = array(
          100 => "scheme_name_1",
          200 => "scheme_name_2"
        );
        if( ! function_exists( "wpadverts_custom_fields_get_form_scheme" ) ) {
            return $args;
        }
        if( isset( $params["add_form_scheme"] ) ) {
            if( ! is_array( $args["meta_query"] ) ) {
                $args["meta_query"] = array();
            }
            $scheme = wpadverts_custom_fields_get_form_scheme( "add", $page_to_fs[get_the_ID()] );
            $args["meta_query"][] = array( 
                "key" => "_wpacf_form_scheme_id", 
                "value" => $scheme->ID 
            );
        }
        return $args;
    }

    where 100 is the ID of the page with the classifieds list block and scheme_name_1 is the name of the form scheme (similarly with 200 and shceme_name_2)

    Thread Starter Triptikon

    (@triptikon)

    Console says, that this line

        if( ! is_array( $args["meta_query"] ) ) {

    contains a mistake: syntax error, unexpected ‘if’ (T_IF)

    Does this mean that after implementing this code, ads on the same page will be displayed according to the language selected by the user? If anything, the site uses the Translatepress plugin

    Plugin Author Greg Winiarski

    (@gwin)

    If you will have the $page_to_fs variable configured correctly the the English page should show only the ads posted using the English Classifieds Publish form and similarly with the other language.

    Not sure about the error i am testing the code on my dev site and it does not produce any errors.

    Thread Starter Triptikon

    (@triptikon)

    Here’s a screenshot: https://ibb.co/1nZngZz

    What do you mean by $page_to_fs variable configured correctly?

    Thread Starter Triptikon

    (@triptikon)

    I sent you an email with a link to the functions.php file of the site’s child theme

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,

    thanks i got it, for some reason when pasting the code into the functions.php file the [ character is converted to [ which is causing a fatal error.

    There is a total of 6 occurrences of this you will need to correct each one to have the code run without errors.

    Thread Starter Triptikon

    (@triptikon)

    The code has been implemented, thank you! However, it did not solve the problem. The same ad list is displayed on two different pages: here and here

    Plugin Author Greg Winiarski

    (@gwin)

    Try replacing

    isset( $params["add_form_scheme"] )

    with

    isset( $page_to_fs[get_the_ID()] ) 

    also note this will only work if the $page_to_fs variable is correctly configured

    Thread Starter Triptikon

    (@triptikon)

    No, with these changes, on one page the list disappears altogether, and on the other only one ad is visible. Please also tell me why the picture added by default to ads is distorted in size? Here’s a screen

    Plugin Author Greg Winiarski

    (@gwin)

    Can you let me know how does your $page_to_fs variable looks like?

    I am testing the below code on my dev site and it seems to be filtering ads correctly when this variable is configured

    add_filter( "adverts_list_query", function( $args, $params ) {
        $page_to_fs = array(
          100 => "scheme_name_1",
          200 => "scheme_name_2"
        );
        if( ! function_exists( "wpadverts_custom_fields_get_form_scheme" ) ) {
            return $args;
        }
        if( isset( $page_to_fs[get_the_ID()] ) ) {
            if( ! is_array( $args["meta_query"] ) ) {
                $args["meta_query"] = array();
            }
            $scheme = wpadverts_custom_fields_get_form_scheme( "add", $page_to_fs[get_the_ID()] );
            $args["meta_query"][] = array( 
                "key" => "_wpacf_form_scheme_id", 
                "value" => $scheme->ID 
            );
        }
        return $args;
    }, 10, 2 );

    The link you sent is showing my a 504 Gateway Time-out error only?

    Thread Starter Triptikon

    (@triptikon)

    Can you let me know how does your $page_to_fs variable looks like

    I can’t understand what the $page_to_fs is

    Here’s another screen

    Plugin Author Greg Winiarski

    (@gwin)

    At the beginning of the function i sent you there is the following variable

        $page_to_fs = array(
          100 => "scheme_name_1",
          200 => "scheme_name_2"
        );

    you need to replace 100, 200 (page IDs), scheme_name_1 and scheme_name_2 (form scheme names) with the actual values that will match the page IDs to form schemes.

    So for example when using the [adverts_list] or Classifieds List block on the Page with ID 100 only then the Ads posted using scheme_name_1 will be shown.

    I can tell that

    so the variable should be something like

        $page_to_fs = array(
          738  => "scheme_name_1",
          1073 => "scheme_name_2"
        );

    where scheme_name_1 should be replaced with the name of the English post-an-ad form and scheme_name_2 with the name of Russian post-an-ad form.

Viewing 15 replies - 61 through 75 (of 83 total)
  • The topic ‘How to organize prices?’ is closed to new replies.