Customize Bill of Lading Template
- Create wpcargo directory in your theme directory. (e.g. child-theme/wpcargo/).
- Create a new file and name it bol.tpl.php.
Note: This will return an empty template.
- If you just need a little changes in your template, you can copy below code and update desired section
<style>
.padding-default{
padding:8px;
}
table{
border-collapse: collapse;
}
table td{
vertical-align:top;
border:1px solid #000;
}
table td *{
margin:0;
padding:0;
}
table#package-table th{
white-space:nowrap;
}
.shipment-info td {
padding:6;
border:none;
}
#package-table td,
#package-table th{
padding:6px;
border:1px solid #000;
}
.border-bottom{
border-bottom: 1px solid #000;
}
.space-topbottom{
padding-top:18px;
padding-bottom:18px;
}
img#log{
width:50% !important;
}
.section-title{
margin-bottom:8px;
text-align:center;
background-color:#333;
color:#fff;
padding: 4px 0;
}
</style>
<table style="width:100%;">
<tr>
<td colspan="2" class="padding-default" style="text-transform: uppercase;text-align:center; font-size:24px;"><?php esc_html_e('Bill of Lading', 'wpcargo-frontend-manager') ?></td>
</tr>
<tr>
<td style="width:50%;">
<h1 class="section-title"><?php esc_html_e('SHIP FROM', 'wpcargo-frontend-manager'); ?></h1>
<div class="padding-default">
<?php echo wpcfe_print_data( 'shipper_info', $shipmentDetails['shipmentID']); ?>
</div>
</td>
<td style="width:50%;" rowspan="2">
<section class="padding-default" style="text-align:center;" >
<img src="<?php echo $wpcargo->barcode_url( $shipmentDetails['shipmentID'], 120 ); ?>">
<p style="font-size:18px;"><?php echo get_the_title( $shipmentDetails['shipmentID']); ?><p>
</section>
</td>
</tr>
<tr>
<td>
<h1 class="section-title"><?php esc_html_e('SHIP TO', 'wpcargo-frontend-manager'); ?></h1>
<div class="padding-default">
<?php echo wpcfe_print_data( 'receiver_info', $shipmentDetails['shipmentID']); ?>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<h1 class="section-title"><?php esc_html_e('ADDITIONAL INFORMATION', 'wpcargo-frontend-manager'); ?></h1>
<div class="padding-default">
<table style="width:100%;" class="shipment-info">
<?php
$field_keys = $WPCCF_Fields->get_custom_fields( 'shipment_info' );
if( !empty( $field_keys ) ){
$counter = 1;
foreach ( $field_keys as $field ) {
$field_data = maybe_unserialize( get_post_meta( $shipmentDetails['shipmentID'], $field['field_key'], TRUE ) );
if( is_array( $field_data ) ){
$field_data = implode(", ", $field_data);
}
if( $counter == 1 ){
echo '<tr>';
}
// table data
echo '<td>';
if( $field['field_type'] == 'file' ){
$files = array_filter( array_map( 'trim', explode(",", $field_data) ) );
if( !empty( $files ) ){
?>
<div class="wpccfe-files-data">
<label><?php echo $field['label']; ?></label><br/>
<div id="wpcargo-gallery-container_<?php echo $field['id'];?>">
<ul class="wpccf_uploads">
<?php
foreach ( $files as $file_id ) {
$att_meta = wp_get_attachment_metadata( $file_id );
?>
<li class="image">
<?php echo get_the_title($file_id); ?>
</li>
<?php
}
?>
</ul>
</div>
</div>
<?php
}
}elseif( $field['field_type'] == 'url' ){
$url_data = maybe_unserialize( get_post_meta( $shipment_id, $field['field_key'], TRUE ) );
$target = count( $url_data ) > 2 ? '_blank' : '' ;
$url = $url_data[1] ? $url_data[1] : '#' ;
$label = $url_data[0];
?><p><?php echo $field['label']; ?>:<br/><a href="<?php echo $url; ?>" target="<?php echo $target; ?>"><?php echo $label; ?></a></p><?php
}else{
?><p><?php echo $field['label']; ?>:<br/><?php echo $field_data; ?></p><?php
}
echo '</td>';
if( $counter == 3 ){
echo '</tr>';
$counter = 1;
continue;
}
$counter++;
}
}
?>
</table>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<h1 class="section-title no-margin"><?php esc_html_e('PACKAGE DETAILS', 'wpcargo-frontend-manager'); ?></h1>
<div class="padding-default">
<table id="package-table" style="width:100%;">
<thead>
<tr>
<?php foreach ( wpcargo_package_fields() as $key => $value): ?>
<?php if( in_array( $key, wpcargo_package_dim_meta() ) && !wpcargo_package_settings()->dim_unit_enable ){ continue; }
?>
<th><?php echo $value['label']; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach ( wpcargo_get_package_data( $shipmentDetails['shipmentID'] ) as $data_key => $data_value): ?>
<tr>
<?php foreach ( wpcargo_package_fields() as $field_key => $field_value): ?>
<?php if( in_array( $field_key, wpcargo_package_dim_meta() ) && !wpcargo_package_settings()->dim_unit_enable ){ continue; } ?>
<td>
<?php
$package_data = array_key_exists( $field_key, $data_value ) ? $data_value[$field_key] : '' ;
echo is_array( $package_data ) ? implode(',', $package_data ) : $package_data;
?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</td>
</tr>
</table>