How to add Location column from your shipping history section in your Frontend Manager Dashboard Table

Here’s how to add column using the last location from your shipping history to WPCargo Frontend Manager Dashboard table. You can use also get the value of the last data or row in your shipping history such as date, time, location, status, updated-name and remark.

Add this code to your functions.php

// How to add custom column on the Frontend Manager dashboard
// * Add table column header
function custom_shipment_table_location_header_callback(){
    ?><td>Location</td>
    <!php 
}
add_action('wpcfe_shipment_table_header', 'custom_shipment_table_location_header_callback');
// * Add table column data
// * Payment Mode metakey is payment_wpcargo_mode_field for this example
function custom_column_location_shipment_table_data_callback( $post_id ){
    $location='';
    $_data = maybe_unserialize( get_post_meta( $post_id , 'wpcargo_shipments_update', true ) );
        if( !empty( $_data ) && is_array( $_data ) ){
                        // Get the last shipment history data
            $last_data = array_pop( $_data );
                        // Note: Each data in the shipment history is an array
                        // Array keys: data, time, location, status, updated-name, remarks
            $location= $last_data['location'];
        } ?>
<td><?php $location; ?></td>
    <?php
}
add_action('wpcfe_shipment_table_data', 'custom_column_location_shipment_table_data_callback');

 

How to add Package Fields, Total Quantity and Volumetric Weight to WPCargo Frontend Manager Dashboard table

 


function wpccustom_dims_header_callback(){
    //Get Dimension Unit from the Settings
    $options    = get_option('wpc_mp_settings');
    $dim        = $options['wpc_mp_dimension_unit'];
    ?>
    <th><?php _e('Total Weight', WPCCUSTOMDASHBOARD_TEXTDOMAIN ); ?> ( <?php echo $options['wpc_mp_weight_unit']; ?> ) </th>
    <th><?php _e('Total Qty', WPCCUSTOMDASHBOARD_TEXTDOMAIN ); ?></th>
    <th><?php _e('DIMS', WPCCUSTOMDASHBOARD_TEXTDOMAIN ); ?> ( <?php echo $dim; ?> )</th>
    <?php
}
add_action('wpcfe_shipment_table_header', 'wpccustom_dims_header_callback');

function wpccustom_pieceTypes_callback( $shipment_id ){
    $options                = get_option('wpc_mp_settings');
    $data                   = wpccustom_format_data( $shipment_id );
    $total_qty              = wpccustom_get_total_quantity( $shipment_id );
    $package_volumetric 	= !empty ( $shipment_id ) ? wpcargo_package_volumetric( $shipment_id ) : '0.00';
    ?>
    <td class="shipment-dims"><?php echo $package_volumetric; ?> <?php echo $options['wpc_mp_weight_unit']; ?></td>
    <td class="shipment-dims"><?php echo $total_qty; ?></td>
    <?php
    if( !empty($data) ):
    ?><td class="shipment-dims">
        <table width = 100% style = "border-collapse:collapse;">
            <?php foreach( $data as $piece => $qty ) :?>
                <tr>
                    <td style = "border:none; padding:0;"><?php echo $piece;?> * <?php echo $qty; ?></td>
                </tr>
            <?php endforeach;?>
        </table>
    </td><?php
    else: ?>
    <td class="shipment-dims"><?php _e('No Package', WPCCUSTOMDASHBOARD_TEXTDOMAIN ); ?></td>
    <?php
    endif;
}
add_action('wpcfe_shipment_table_data', 'wpccustom_pieceTypes_callback');

function wpccustom_get_total_quantity( $sid ){
    $wpc_multiple_package   = maybe_unserialize( get_post_meta( $sid, 'wpc-multiple-package', true ) );
    $total_qty              = 0.00;
    foreach( $wpc_multiple_package as $package ):
        $total_qty += $package['wpc-pm-qty'];
    endforeach;

    return $total_qty;
}

function wpccustom_format_data( $sid ){
    $wpc_multiple_package   = maybe_unserialize( get_post_meta( $sid, 'wpc-multiple-package', true ) );
    $packages               = array();
    $sorted_piece           = array();
    $sorted_data            = array();

    //Restructure package fields array
    foreach( $wpc_multiple_package as $package ):
        if( !empty( $package['wpc-pm-length'] ) || !empty( $package['wpc-pm-width'] ) || !empty( $package['wpc-pm-height'] ) ):
        $dims = $package['wpc-pm-length'].'*'.$package['wpc-pm-width'].'*'.$package['wpc-pm-height'];
        $packages[] = array(
            'qty' => $package['wpc-pm-qty'],
            'dims' =>$dims
        );
        endif;
    endforeach;
    //Count quantity per dimension
    foreach( $packages as $piece ):
        $sorted_data[$piece['dims']] += $piece['qty'];
    endforeach;

    return $sorted_data;
}

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