Automattic\WooCommerce\Internal\Utilities
ProductUtil::append_product_sorting_table_join
Append the product meta lookup join unless the clause mentions wc_product_meta_lookup as a standalone token. References, SQL literals and comments also count as mentions; this is not an SQL parser.
Method of the class: ProductUtil{}
No Hooks.
Returns
string.
Usage
$ProductUtil = new ProductUtil(); $ProductUtil->append_product_sorting_table_join( $join ): string;
- $join(mixed) (required)
- SQL JOIN clause supplied by query filters.
Changelog
| Since 11.2.0 | Introduced. |
ProductUtil::append_product_sorting_table_join() ProductUtil::append product sorting table join code WC 11.2.2
public function append_product_sorting_table_join( $join ): string {
global $wpdb;
// Preserve stringable clauses: discarding a join can break a WHERE clause that still references it.
if ( ! is_string( $join ) ) {
$stringable = is_object( $join ) && method_exists( $join, '__toString' );
$join = $stringable ? (string) $join : '';
}
// A non-empty wpdb prefix prevents a table-name match. Empty prefixes retain the old guard's limitation.
if ( ! preg_match( '/\bwc_product_meta_lookup\b/', $join ) ) {
$join .= " LEFT JOIN {$wpdb->wc_product_meta_lookup} wc_product_meta_lookup ON $wpdb->posts.ID = wc_product_meta_lookup.product_id ";
}
return $join;
}