How to modify fields in shipment history?

Can I modify fields in shipment history?

Yes you can. Copy and paste the following code in your child theme’s functions.php file.

add_filter( 'wpcargo_history_fields', 'modify_history_fields', 10, 1 );
function modify_history_fields( $history_fields ){
	//Remove fields
	unset( $history_fields['date'] );
	unset( $history_fields['time'] );
	unset( $history_fields['location'] );
	unset( $history_fields['status'] );
	unset( $history_fields['updated-name'] );
	unset( $history_fields['remarks'] );
	
	//Add fields
	$history_fields['new-field'] = array( 
		'label' => __('New Field', 'wpcargo'),
		'field' => 'text',
		'required' => false,
		'options' => array()
	);
	
    //Changing required field by changing value to  false or true 
	$history_fields['location'] = array( 
		'label' => __('Location', 'wpcargo'),
		'field' => 'text',
		'required' => false,
		'options' => array()
	);

	//Update label of field
	$history_fields['updated-name']['label'] = 'New Label';
	return $history_fields;
}

To remove shipment history column from the track result page, copy this code on your child theme’s functions.php:

add_filter( 'wpcargo_history_fields', 'modify_history_fields', 10, 1 );
function modify_history_fields( $history_fields ){
	if(isset( $_REQUEST['wpcargo_tracking_number'] )){
		unset( $history_fields['updated-name'] );
	}
	return $history_fields;
}

To remove the required attributes in all of the shipment history fields, copy this code on your child theme’s functions.php:

add_filter( 'wpcargo_history_fields', 'modify_history_fields', 10, 1 );
function modify_history_fields( $history_fields ){
    //Remove fields
    $history_fields['date']['required'] = false ;
    $history_fields['time']['required'] = false ;
    $history_fields['location']['required'] = false ;
    $history_fields['status']['required'] = false ;
    $history_fields['updated-name']['required'] = false ;
    $history_fields['remarks']['required'] = false ;
     
    return $history_fields;
}

[/php]

To add custom fields in all of the shipment history fields, copy this code on your child theme’s functions.php:

add_filter( 'wpcargo_history_fields', 'custom_additional_history_fields', 10, 1 );
function custom_additional_history_fields( $history_fields ){
    //Add custom field
   $history_fields['custom'] = array(
            'label' => esc_html__('New Field', 'wpcargo'),
            'field' => 'text',
            'required' => 'false',
            'options' => array()
        );
    return $history_fields;
}
3
    3
    Your Cart
    Remove
    WPCargo Standard Package
    2 X $119.00 = $238.00
    Remove
    WPCargo User Management
    1 X $39.00 = $39.00
    Placeholder Remove
    Translation Service
    2 X $89.00 = $178.00