wc_get_template

Get other templates (e.g.

Description

wc_get_template( (string) $template_name, (array) $args = array(), (string) $template_path = '', (string) $default_path = '' ); 

product attributes) passing attributes and including the file.

Parameters (4)

0. $template_name (string)
The template name.
1. $args — Optional. (array) => array()
(default: array())
2. $template_path — Optional. (string) => ''
The template path.
3. $default_path — Optional. (string) => ''
The default path.

Usage

  1. if ( !function_exists( 'wc_get_template' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
  3.  
  4. // The template name. 
  5. $template_name = ''; 
  6.  
  7. // (default: array()) 
  8. $args = array(); 
  9.  
  10. // The template path. 
  11. $template_path = ''; 
  12.  
  13. // The default path. 
  14. $default_path = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wc_get_template($template_name, $args, $template_path, $default_path); 
  18.  

Defined (1)

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

/includes/wc-core-functions.php  
  1. function wc_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { 
  2. if ( ! empty( $args ) && is_array( $args ) ) { 
  3. extract( $args ); 
  4.  
  5. $located = wc_locate_template( $template_name, $template_path, $default_path ); 
  6.  
  7. if ( ! file_exists( $located ) ) { 
  8. wc_doing_it_wrong( __FUNCTION__, sprintf( __( '%s does not exist.', woocommerce ), '<code>' . $located . '</code>' ), '2.1' ); 
  9. return; 
  10.  
  11. // Allow 3rd party plugin filter template file from their plugin. 
  12. $located = apply_filters( 'wc_get_template', $located, $template_name, $args, $template_path, $default_path ); 
  13.  
  14. do_action( 'woocommerce_before_template_part', $template_name, $template_path, $located, $args ); 
  15.  
  16. include( $located ); 
  17.  
  18. do_action( 'woocommerce_after_template_part', $template_name, $template_path, $located, $args );