• Resolved kxeilakos

    (@kxeilakos)


    Hi there,

    first, I wish you a Happy new Year!
    I am building a custom page using Elementor builder. Is it possible to display the YMM dropdowns inside this page, or using a sidebar or a widget in general is mandatory?

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    You should be able to add it with shortcode:

    
    [ymm_selector template="horizontal_selector.php"]
    

    Stanislav

    Thread Starter kxeilakos

    (@kxeilakos)

    Yes, it works, thank you very much for your instant response. I placed it on a custom page and once it retrieves the products it redirects to the category / cart page to display the grid.

    Is it possible to display the products on the same page on a grid without re-directing to the category / cart page?

    this is my page: https://krikellas.gr/black-friday/

    There is a Horizontal YMM filter and an Archive Products element below the filter. Is it possible to display the filtered products in the specific grid and remain on the /black-friday/ page ?

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    To make it redirect to a custom page as search results page:

    Try to replace the line:

    
     return home_url( '/' );
    

    with:

    
     return home_url( '/black-friday/' );
    

    in the file:
    wp-content/plugins/ymm-search/Block/Selector.php`

    Then use a shortcode like this:

    
    [products]
    

    To display products on your custom wordpress page.

    To make those products filtered by the current selected make, make and year:
    Add the line:

    
        add_filter( 'woocommerce_shortcode_products_query', array($this, 'filter_shortcode_products_query' ));
    

    after the line:

    
    add_filter('get_search_query', array($this, 'shop_order_search_label' ));
    

    And add the code:

    
    public function filter_shortcode_products_query($query_args) {
    
        $values = $this->getSelectedValues();
        $pIds = $this->getFoundProductIds();
    
        if (count($values) > 0){
          $query_args['post__in'] = count($pIds) > 0 ? $pIds : array(-1); // -1 to display a "no products found" message
        }
        
        return $query_args;		
      }
    

    before the line:

    
      public function applyFilter(){
    

    in the file:
    wp-content/plugins/ymm-search/Controller/Product.php

    NOTE: You can add attributes to the products shortcode like “columns”, “orderby”:
    https://woocommerce.com/document/woocommerce-shortcodes/#available-product-attributes

    Stanislav

    Thread Starter kxeilakos

    (@kxeilakos)

    Great resposne! Thank you very much. I really appreciate your help on this!

    @pektsekye, first, thank you SO MUCH for this plug-in. I’d like to send you $$ once I get it working on our new website. I am also using Elementor and am following your instructions here.

    Our issue is that when you enter an application and click Search, it only just loads the Elementor Archives product category view with all categories present without any filtering being applied.

    I decided to try the notes above in this thread by creating a new ordinary Page and inserting both the YMM shortcode as “[ymm_selector template=”selector.php” garage=1]” and below that the products shortcode as “[products]”.

    When I load the page, for example “www.site.com/select-your-vehicle“, the page takes a very long time to load as it displays all 1000+ of our products without any category structure. Then, when I make a selection and click Search, it loads a 404 page for “Page not found” despite still being on the proper URL of, for example, “www.site.com/select-your-vehicle?ymm_search=1&post_type=product&_make=Toyota&_model=Tacoma&_year=2018″

    Line 256 of my Block/Selector.php is: “return home_url( ‘/select-your-vehicle/’ );”

    Thank you for the assistance!

    Plugin Author Pektsekye

    (@pektsekye)

    Hello,

    To: @huusoku

    Can you send a link of your website to my email [email protected]

    ?

    Stanislav

    Thank you for the help, Stanislav!! Excellent support. My issue was that despite what I posted above ???????♂?, I actually had in my Selector.php file:

    return home_url( '/select-your-vehicle' );

    instead of

    return home_url( '/select-your-vehicle/' );

    Once I added that trailing ‘/’ it worked. Stanislav then also provided a tip to replace “.done” with “.success” in main.js and now it is functioning as expected.

    Another tip which is not new to many but was new to me is that the [products] shortcode can be improved with pagination, for example, [products paginate=”true” limit=25], so that your poor server doesn’t try to load your entire database of products ??

    Next, I am working on a way to have a “Remove Vehicle” option to remove the currently selected vehicle from the garage as well as how to get YMM to function with the Elementor widget “Archive Products”, which provides a Category view instead of a bunch of dumped, unsorted product view through the [products] shortcode method.

    I’ll keep this updated to help others, and thank you again Stanislav! Looking forward to having this fully set up!

    Regards,
    Huusoku

    • This reply was modified 10 months, 1 week ago by huusoku.
    • This reply was modified 10 months, 1 week ago by huusoku.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Shortcode to display YMM plugin’ is closed to new replies.