Hi @rekers
We would like to better understand which address information you would like to display on all pages and where exactly it should appear.
Could you please share a screenshot or sample PDF showing the issue?
Just to clarify, do you mean that when the document has 2–3 pages, you would like the customer’s address information to be displayed on all pages instead of only the first page?
Please let us know so we can guide you accordingly.
Thread Starter
rekers
(@rekers)
Yes, I would like the address information on pages 2 and 3 to be the same as on the first page.
It’s not common to have 2 or 3 pages, but it does happen from time to time.
Hi @rekers
Thank you for clarifying.
You can create a table header so it will appear before the table and automatically repeat on every printed page. You can use the filter below, and it will work only for the packing slip template.
add_action( 'wcdn_before_items', 'custom_wcdn_packingslip_repeat_header', 1, 2 );
function custom_wcdn_packingslip_repeat_header( $order, $template ) {
if ( 'packingslip' !== $template ) {
return;
}
?>
<style>
@media print {
.wcdn-items thead {
display: table-header-group;
}
.wcdn-repeat-address-row th {
text-align:left;
padding-bottom:15px;
border-bottom:1px solid #ccc;
}
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
var table = document.querySelector('.wcdn-items');
if (!table) {
return;
}
var thead = table.querySelector('thead');
if (!thead) {
return;
}
var repeatRow = document.createElement('tr');
repeatRow.className = 'wcdn-repeat-address-row';
repeatRow.innerHTML = <br> <th colspan="2"><br><br> <table width="100%"><br> <tr><br><br> <td style="width:50%; vertical-align:top;"><br><br> <strong>Billing Address</strong><br><br><br><br> <?php echo esc_js( $order['billing']['name'] ?? '' ); ?><br><br><br> <?php<br> if ( ! empty( $order['billing']['address'] ) ) {<br><br> foreach ( $order['billing']['address'] as $line ) {<br><br> echo esc_js( $line ) . '<br>';<br> }<br> }<br> ?><br><br> </td><br><br> <td style="width:50%; vertical-align:top;"><br><br> <strong>Shipping Address</strong><br><br><br><br> <?php echo esc_js( $order['shipping']['name'] ?? '' ); ?><br><br><br> <?php<br> if ( ! empty( $order['shipping']['address'] ) ) {<br><br> foreach ( $order['shipping']['address'] as $line ) {<br><br> echo esc_js( $line ) . '<br>';<br> }<br> }<br> ?><br><br> </td><br><br> </tr><br> </table><br><br> </th><br>;
thead.prepend(repeatRow);
});
</script>
<?php
}
Also, for the first page, you can disable the default billing/shipping section because this snippet will add the billing/shipping details on the first page as well.
Please note that this will not work for PDF generation. If you want the same behavior in PDF, then it would require complete template customization.
Screenshot for your reference – https://prnt.sc/7FsFCXsadRjv
Please check it on your end and let us know if there are any further questions.