How to add Employee, Client and other WPCargo user role in shipment table?

In adding Employee Client and other WPCargo user roles to the shipment list is very easy, just follow this steps.

Note: Each WPCargo user role has it’s own metakey assign to the shipment. the following list are the assigned metakeys for each role.

  • Branch Manager – wpcargo_branch_manager
  • WPCargo Employee – wpcargo_employee
  • WPCargo Agent – agent_fields
  • WPCargo Client – registered_shipper
  • WPCargo Driver – wpcargo_driver

In this sample code we’re going to add a new column for the Shipment Assigned Employee

  1. Add hook for the shipment table header using the “wpcfe_shipment_table_header” action hook.

     
                function wpcfe_shipment_table_header_callback(){
                    echo "<th>Assigned Employeee</th>";
                }
                add_action('wpcfe_shipment_table_header', 'wpcfe_shipment_table_header_callback');
            
  2. Add hook for the column row data for the Employee Column using the “wpcfe_shipment_table_data” action hook.

     
                function wpcfe_shipment_table_data_callback( $shipment_id ){
                    global $wpcargo; 
                    /*
                     * Change the "wpcargo_employee" parameter and use the other user role metakey to display each users.
                     *
                     */
                    $employee = get_post_meta( $shipment_id, 'wpcargo_employee', true );
                    $data = "<td>";
                    $data .= $wpcargo->user_fullname( $employee );
                    $data .= "</td>";
                    echo $data;
                }
                add_action("wpcfe_shipment_table_data", "wpcfe_shipment_table_data_callback");
            

    Note: In this process we used “$wpcargo” global variable to display the Employe full name. “wpcargo_employee” save the employee user ID and not the employee full name.

To add other data in the shipment task visit this documentation on how to add custom column in shipments table.

1
    1
    Your Cart
    Remove