How to remove sections in adding/updating shipments

Add this code to your child theme’s functions.php file:

add_filter( 'wpcfe_shipment_sections', 'custom_shipment_sections' );
function custom_shipment_sections( $formatted_section ){
	//Remove Shipper Information Section
	unset( $formatted_section['shipper_info'] );

	//Remove Receiver Information Section
	unset( $formatted_section['receiver_info'] );

	//Remove Shipment Information Section
	unset( $formatted_section['shipment_info'] );
	
	return $formatted_section;
}

add_action( 'wp_head', 'remove_section', 10 );
function remove_section(){
	//Assign To Section
	remove_action( 'before_wpcfe_shipment_form_submit', 'wpcfe_assigned_shipment_template', 40, 1 );

	//Package Information Section
	remove_action( 'after_wpcfe_shipment_form_fields', 'wpcfe_shipment_multipackage_template', 10, 1 );

	//History Records Section
	remove_action( 'after_wpcfe_shipment_form_fields', 'wpcfe_shipment_history_table_template', 10, 2 );

	//History Section
	remove_action( 'before_wpcfe_shipment_form_submit', 'wpcfe_shipment_history_template', 60, 1 );
}

Below example removes section by role.

NOTE: For removing of sections on client’s user role, change “cargo_agent” to “wpcargo_client“.

add_filter( 'wpcfe_shipment_sections', 'custom_shipment_sections' );
function custom_shipment_sections( $formatted_section ){
	//Check user role
	$user_roles = wpcfe_current_user_role();

	//Remove sections for agents
	if( in_array( 'cargo_agent', (array)$user_roles ) ){
		//Remove Shipper Information Section
		unset( $formatted_section['shipper_info'] );

		//Remove Receiver Information Section
		unset( $formatted_section['receiver_info'] );

		//Remove Shipment Information Section
		unset( $formatted_section['shipment_info'] );
	}
	return $formatted_section;
}

add_action( 'wp_head', 'remove_section', 10 );
function remove_section(){
	//Check user role
	$user_roles = wpcfe_current_user_role();
	
	//Remove sections for agents
	if( in_array( 'cargo_agent', (array)$user_roles ) ){
		//Assign To Section
		remove_action( 'before_wpcfe_shipment_form_submit', 'wpcfe_assigned_shipment_template', 40, 1 );

		//Package Information Section
		remove_action( 'after_wpcfe_shipment_form_fields', 'wpcfe_shipment_multipackage_template', 10, 1 );

		//History Records Section
		remove_action( 'after_wpcfe_shipment_form_fields', 'wpcfe_shipment_history_table_template', 10, 2 );

		//History Section
		remove_action( 'before_wpcfe_shipment_form_submit', 'wpcfe_shipment_history_template', 60, 1 );
	}
}

SHIPPER DETAILS SECTION

shipper-details

RECEIVER DETAILS SECTION

receiver-details

SHIPMENT INFORMATION SECTION

wpcfe-shipment-info

ASSIGN SHIPMENT TO SECTION

wpcfe-assign-shipment

PACKAGES SECTION

packages
0
    0
    Your Cart
    Your cart is emptyReturn to Shop