How to use other meta key in Scanning Barcode

Using Shipper Name fieldwpcargo_shipper_name

add_filter('receiving_shipment_update_sql', 'custom_receiving_shipment_update_sql', 10, 3);
function custom_receiving_shipment_update_sql( $sql, $search, $form_data ){
        global $wpdb;
        $prefix = $wpdb->prefix;
	/*
	Default: $sql = "SELECT ID FROM wp_posts WHERE post_title='".$shipment_number."' AND post_status='publish'";
	$search 	- (String) This is the scanned value.
	$form_data 	- (Array) This are the data of shipment history
	*/
	$sql = "SELECT tbl1.ID FROM ".$prefix."posts as tbl1 INNER JOIN ".$prefix."postmeta as tbl2 on tbl1.ID = tbl2.post_id WHERE tbl2.meta_key='wpcargo_shipper_name' AND tbl2.meta_value = '{$search}' AND tbl1.post_status='publish' AND tbl1.post_type = 'wpcargo_shipment'";
	return $sql;
}

Steps to do:

  1. Grab a shipment’s shipper name.

2. Go to “Receiving” page and set the status and other info for the shipment and enter the shipper name.

3. Go back to “Shipments” page and check the shipment’s info.

0
    0
    Your Cart
    Your cart is emptyReturn to Shop