get_product_search_form

Display product search form.

Description

(string) get_product_search_form( (bool) $echo = true ); 

Will first attempt to locate the product-searchform.php file in either the child or. the parent, then load it. If it doesn't exist, then the default search form. will be displayed.

The default searchform uses html5.

Returns (string)

Parameters (1)

0. $echo — Optional. (bool) => true
(default: true)

Usage

  1. if ( !function_exists( 'get_product_search_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-template-functions.php'; 
  3.  
  4. // (default: true) 
  5. $echo = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_product_search_form($echo); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-template-functions.php  
  1. function get_product_search_form( $echo = true ) { 
  2. global $product_search_form_index; 
  3.  
  4. ob_start(); 
  5.  
  6. if ( empty( $product_search_form_index ) ) { 
  7. $product_search_form_index = 0; 
  8.  
  9.  
  10. wc_get_template( 'product-searchform.php', array( 
  11. 'index' => $product_search_form_index++,  
  12. ) ); 
  13.  
  14. $form = apply_filters( 'get_product_search_form', ob_get_clean() ); 
  15.  
  16. if ( $echo ) { 
  17. echo $form; 
  18. } else { 
  19. return $form;