Automattic\WooCommerce\Admin\API\Reports
Segmenter::prepare_selections()
Filters definitions for SELECT clauses based on query_args and joins them into one string usable in SELECT clause.
Method of the class: Segmenter{}
No Hooks.
Return
String
. to be used in SELECT clause statements.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_selections( $columns_mapping );
- $columns_mapping(array) (required)
- Column name -> SQL statememt mapping.
Segmenter::prepare_selections() Segmenter::prepare selections code WC 8.7.0
protected function prepare_selections( $columns_mapping ) { if ( isset( $this->query_args['fields'] ) && is_array( $this->query_args['fields'] ) ) { $keep = array(); foreach ( $this->query_args['fields'] as $field ) { if ( isset( $columns_mapping[ $field ] ) ) { $keep[ $field ] = $columns_mapping[ $field ]; } } $selections = implode( ', ', $keep ); } else { $selections = implode( ', ', $columns_mapping ); } if ( $selections ) { $selections = ',' . $selections; } return $selections; }