WC_Admin_List_Table_Products::append_product_sorting_table_join
Join wc_product_meta_lookup to posts if not already joined.
Method of the class: WC_Admin_List_Table_Products{}
No Hooks.
Returns
string.
Usage
// private - for code of main (parent) class only $result = $this->append_product_sorting_table_join( $sql );
- $sql(string) (required)
- SQL join.
WC_Admin_List_Table_Products::append_product_sorting_table_join() WC Admin List Table Products::append product sorting table join code WC 11.1.0
private function append_product_sorting_table_join( $sql ) {
global $wpdb;
// Another posts_clauses callback produced this clause, so it is not guaranteed to be a string.
// Keep anything that can become one: discarding a join while the WHERE that depends on it
// survives would leave a broken query rather than a merely unfiltered one.
if ( ! is_string( $sql ) ) {
$stringable = is_scalar( $sql ) || ( is_object( $sql ) && method_exists( $sql, '__toString' ) );
$sql = $stringable ? (string) $sql : '';
}
if ( ! strstr( $sql, 'wc_product_meta_lookup' ) ) {
$sql .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
}
return $sql;
}