WC_Shortcode_Products::set_skus_query_args
Set skus query args.
Method of the class: WC_Shortcode_Products{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->set_skus_query_args( $query_args );
- $query_args(array) (required) (passed by reference — &)
- Query args.
Changelog
| Since 3.2.0 | Introduced. |
WC_Shortcode_Products::set_skus_query_args() WC Shortcode Products::set skus query args code WC 10.4.3
protected function set_skus_query_args( &$query_args ) {
if ( ! empty( $this->attributes['skus'] ) ) {
$skus = array_map( 'trim', explode( ',', $this->attributes['skus'] ) );
$query_args['meta_query'][] = array(
'key' => '_sku',
'value' => 1 === count( $skus ) ? $skus[0] : $skus,
'compare' => 1 === count( $skus ) ? '=' : 'IN',
);
}
}