wpcfe_after_shipment_filters

“wpcfe_after_shipment_filters” action hook allow to add additional custom filter field for the shipment table filter.

Copy and paste the following code to add custom filter field.


// Create custom field for the filter section
add_action( 'wpcfe_after_shipment_filters', function(){
	?>
	<div id="my_custom-fields" class="form-group wpcfe-filter my_custom-filter p-0 mx-1">
        <div class="md-form form-group">
            <input id="mycustom-filter" type="text" name="mycustom-filter" class="form-control form-control-sm " placeholder="Custom Filter" value="" autocomplete="off" style="width: 120px;">
        </div>
    </div>
	<?php
}, 100 );

To be able to make the custom field work, We will add the filter data to the page query arguments.

Copy and page this sample code for the filter argument to the theme functions.php file.


add_filter( 'wpcfe_dashboard_arguments', function( $args ){
	// make sure that the custom field exist "mycustom-filter" name attribute
	if( isset($_GET['mycustom-filter']) ){
		// Add meta query to for the metakey "my_custom_meta" filter
		$args['meta_query']['mycustom-filter'] = array(
			'key' => 'my_custom_meta', // Custom metakey registered in the shipment to filter
			'value' => sanitize_text_field( $_GET['mycustom-filter'] ),
			'compare' => 'LIKE'
		);
	}
	return $args;
} );

0
    0
    Your Cart
    Your cart is emptyReturn to Shop