How to Customize Assigned Shipments Table

Customize Assigned Shipments Table

  1. Remove the current track result details
  2. Add new function callback
  3. Copy/ Paste the code to modify shipment table

Screenshot 1.1

PHP CODE:

// remove current result
remove_action( 'container_track_result_after_details', 'container_track_assigned_shipment_callback', 10, 1 );

// add new callback
add_action( 'container_track_result_after_details', 'custom_container_track_assigned_shipment_callback', 10, 1 );
function custom_container_track_assigned_shipment_callback( $container_id ){

    global $wpcargo;

    $shipments      = wpc_shipment_container_get_assigned_shipment( $container_id );

    if( empty($shipments) ){

        return false;

    }

    $total_qty = 0;

    $shipment_count         = count( $shipments );

    $packageDummy = array();

    $packageDummy['0'] = array(

        "wpc-pm-piece-type" => "-",

        "wpc-pm-qty" => 0,

        "wpc-pm-height" => 0,

        "wpc-pm-width" => 0,

        "wpc-pm-length" => 0,

    );

    ?>

    <div id="container-shipments" class="col-sm-12 my-4">

        <p class="section-header h5-responsive font-weight-normal pb-2 border-bottom"><?php echo wpc_scpt_assinged_container_label(); ?></p>

        <div class="container-fluid w-100 m-0">

            <div class="row">

                <table id="wpcfe-packages-repeater" class="table table-hover table-sm">

                    <thead>

                        <tr>

                            <th><strong><?php _e("Type", "wpcargo-servify-integration");?></strong></th>

                            <th><strong><?php _e("Dimensions", "wpcargo-servify-integration");?></strong></th>

                            <th><strong><?php _e("Qty.", "wpcargo-servify-integration");?></strong></th>

                        </tr>

                    </thead>

                    <tbody>

                        <?php foreach( $shipments as $shipment_id):?>

                            <?php

                            $packages = get_post_meta( $shipment_id, 'wpc-multiple-package', true )?:$packageDummy;

                                foreach($packages as $package):

                                    $type = isset($package["wpc-pm-piece-type"])?($package["wpc-pm-piece-type"]?:"-"):"-";

                                    $quantity = isset($package["wpc-pm-qty"])?($package["wpc-pm-qty"]?:0):0;

                                    $height = isset($package["wpc-pm-height"])?($package["wpc-pm-height"]?:0):0;

                                    $width = isset($package["wpc-pm-width"])?($package["wpc-pm-width"]?:0):0;

                                    $length = isset($package["wpc-pm-length"])?($package["wpc-pm-length"]?:0):0;

                                   

                                    $total_qty += (int)$quantity;

                                ?>

                                <tr>

                                    <td><?php echo $type;?></td>

                                    <td><?php echo $height ." x ". $width ." x ". $length;?></td>

                                    <td><?php echo $quantity;?></td>

                                </tr>

                                <?phpendforeach;?>

                        <?php endforeach;?>

                        <tr>

                            <td colspan="3">

                                <strong>

                                    <?php _e("Total Quantity: ", "wpcargo-servify-integration");?><?php echo $total_qty;?>

                                </strong>

                            </td>

                        </tr>  

                    </tbody>

                </table>

            </div>

        </div>  

    </div>

    <?php

}
0
    0
    Your Cart
    Your cart is emptyReturn to Shop