How to Customize Assigned Shipments Table
Customize Assigned Shipments Table
- Remove the current track result details
- Add new function callback
- Copy/ Paste the code to modify shipment table
Screenshot 1.1
PHP CODE:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | // 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 } |