1. Home
  2. Pick List
  3. Hooks & Custom Code
  4. Filter prepared batch

Filter prepared batch

Hook: cas_pick_batch_items_prepared_data

Use this filter to customize prepared batch item rows before they are rendered in the Batch Picking table or in the printed batch view.


What it can be used for

  • Change the sorting of batch items
  • Group certain product types together
  • Push specific products to the top or bottom
  • Apply custom warehouse logic before print and display


Filter signature

/**
 * Filter prepared batch item rows before rendering table or print output.
 *
 * @param array  $data      Prepared batch item rows.
 * @param string $orderby   Current sort column.
 * @param string $order     Current sort direction.
 * @param array  $items_raw Raw batch items from DB.
 *
 * @return array
 */
apply_filters( 'cas_pick_batch_items_prepared_data', $data, $orderby, $order, $items_raw );


Example

add_filter( 'cas_pick_batch_items_prepared_data', function( $data, $orderby, $order, $items_raw ) {
	usort( $data, function( $a, $b ) {
		return strcasecmp(
			isset( $a['_product_name'] ) ? $a['_product_name'] : '',
			isset( $b['_product_name'] ) ? $b['_product_name'] : ''
		);
	} );

	return $data;
}, 10, 4 );

How can we help?