wc_attribute_orderby

Get a product attributes orderby setting.

Description

(string) wc_attribute_orderby( (string) $name ); 

Returns (string)

Parameters (1)

0. $name (string)
The name.

Usage

  1. if ( !function_exists( 'wc_attribute_orderby' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-attribute-functions.php'; 
  3.  
  4. // The name. 
  5. $name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_attribute_orderby($name); 
  9.  

Defined (1)

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

/includes/wc-attribute-functions.php  
  1. function wc_attribute_orderby( $name ) { 
  2. global $wc_product_attributes, $wpdb; 
  3.  
  4. $name = str_replace( 'pa_', '', sanitize_title( $name ) ); 
  5.  
  6. if ( isset( $wc_product_attributes[ 'pa_' . $name ] ) ) { 
  7. $orderby = $wc_product_attributes[ 'pa_' . $name ]->attribute_orderby; 
  8. } else { 
  9. $orderby = $wpdb->get_var( $wpdb->prepare( "SELECT attribute_orderby FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $name ) ); 
  10.  
  11. return apply_filters( 'woocommerce_attribute_orderby', $orderby, $name );