Suggestions customizations

Tagged:
  • abdulazizasif
    Participant
    1 year, 12 months ago #46263

    Hi,

    I am using “Suggestions” with the search box at the front-end. It is displaying properly when user starts typing in the keyword.

    Now, I want the customize the data showing in the suggestions box. Please explain how to replace WooCommerce pricing with custom pricing and change the template with twig.

    Thanks
    ASIF

    wpsolr
    Keymaster
    1 year, 12 months ago #46266

    You can find a full example in the plugin’s root folder “wpsolr-examples”.

    use wpsolr\core\classes\WPSOLR_Events;
    
    // Add/update some extra data to be shown in your local template
    add_filter( WPSOLR_Events::WPSOLR_ACTION_BEFORE_RENDER_TEMPLATE, function ( $template_params ) {
      
      // Prefix all results titles
      foreach ( $template_params['template_data']['results'] as $post_type => &$result ) {
          foreach ( $result['items'] as &$item ) {
    	  $item['title']['title'] = '$$$ ' . $item['title']['title'];
          }
      }
    
    });
    wpsolr
    Keymaster
    1 year, 12 months ago #46267

    Then copy all suggestions twig templates in your child theme, and modify them to show your custom data.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.