Skip to content

Commit

Permalink
Fix: bug on footer not fixed in bottom on Simple mPDF and RTL templat…
Browse files Browse the repository at this point in the history
…es (#12)
  • Loading branch information
alexmigf authored Apr 6, 2023
1 parent 9db7599 commit be22265
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 108 deletions.
59 changes: 34 additions & 25 deletions templates/Simple RTL/invoice.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_document', $this->get_type(), $this->order ); ?>

<table class="head container">
<tr>
<td class="header">
<?php
if( $this->has_header_logo() ) {
if ( $this->has_header_logo() ) {
do_action( 'wpo_wcpdf_before_shop_logo', $this->get_type(), $this->order );
$this->header_logo();
do_action( 'wpo_wcpdf_after_shop_logo', $this->get_type(), $this->order );
} else {
echo $this->get_title();
}
?>
</td>
<td class="shop-info">
<?php do_action( 'wpo_wcpdf_before_shop_name', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_name', $this->get_type(), $this->order ); ?>
<div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
<?php do_action( 'wpo_wcpdf_after_shop_name', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shop_name', $this->get_type(), $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_address', $this->get_type(), $this->order ); ?>
<div class="shop-address"><?php $this->shop_address(); ?></div>
<?php do_action( 'wpo_wcpdf_after_shop_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shop_address', $this->get_type(), $this->order ); ?>
</td>
</tr>
</table>

<?php do_action( 'wpo_wcpdf_before_document_label', $this->get_type(), $this->order ); ?>

<h1 class="document-type-label">
<?php if( $this->has_header_logo() ) echo $this->get_title(); ?>
<?php if ( $this->has_header_logo() ) echo $this->get_title(); ?>
</h1>

<?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_document_label', $this->get_type(), $this->order ); ?>

<table class="order-data-addresses">
<tr>
<td class="address billing-address">
<!-- <h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->get_type(), $this->order ); ?>
<?php $this->billing_address(); ?>
<?php do_action( 'wpo_wcpdf_after_billing_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_billing_address', $this->get_type(), $this->order ); ?>
<?php if ( isset($this->settings['display_email']) ) { ?>
<div class="billing-email"><?php $this->billing_email(); ?></div>
<?php } ?>
Expand All @@ -46,14 +50,14 @@
<td class="address shipping-address">
<?php if ( !empty($this->settings['display_shipping_address']) && ( $this->ships_to_different_address() || $this->settings['display_shipping_address'] == 'always' ) ) { ?>
<h3><?php _e( 'Ship To:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->get_type(), $this->order ); ?>
<?php $this->shipping_address(); ?>
<?php do_action( 'wpo_wcpdf_after_shipping_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shipping_address', $this->get_type(), $this->order ); ?>
<?php } ?>
</td>
<td class="order-data">
<table>
<?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_order_data', $this->get_type(), $this->order ); ?>
<?php if ( isset($this->settings['display_number']) ) { ?>
<tr class="invoice-number">
<th><?php echo $this->get_number_title(); ?></th>
Expand All @@ -78,13 +82,13 @@
<th><?php _e( 'Payment Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
<td><?php $this->payment_method(); ?></td>
</tr>
<?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_order_data', $this->get_type(), $this->order ); ?>
</table>
</td>
</tr>
</table>

<?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_order_details', $this->get_type(), $this->order ); ?>

<table class="order-details">
<thead>
Expand All @@ -96,11 +100,11 @@
</thead>
<tbody>
<?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->get_type(), $this->order, $item_id ); ?>">
<td class="product">
<?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
<span class="item-name"><?php echo $item['name']; ?></span>
<?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_item_meta', $this->get_type(), $item, $this->order ); ?>
<div class="item-meta"><?php echo $item['meta']; ?></div>
<ul class="meta">
<?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
Expand All @@ -111,7 +115,7 @@
<li class="weight"><strong class="weight-label"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></strong> <?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></li>
<?php endif; ?>
</ul>
<?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_item_meta', $this->get_type(), $item, $this->order ); ?>
</td>
<td class="quantity"><?php echo $item['quantity']; ?></td>
<td class="price"><?php echo $item['order_price']; ?></td>
Expand Down Expand Up @@ -158,13 +162,18 @@
</tbody>
</table>

<?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_order_details', $this->get_type(), $this->order ); ?>

<div class="bottom-spacer"></div>

<?php if ( $this->get_footer() ): ?>
<div id="footer">
<!-- hook available: wpo_wcpdf_before_footer -->
<?php $this->footer(); ?>
<!-- hook available: wpo_wcpdf_after_footer -->
</div><!-- #letter-footer -->
<htmlpagefooter name="docFooter">
<div id="footer">
<!-- hook available: wpo_wcpdf_before_footer -->
<?php $this->footer(); ?>
<!-- hook available: wpo_wcpdf_after_footer -->
</div><!-- #letter-footer -->
</htmlpagefooter>
<?php endif; ?>
<?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>

<?php do_action( 'wpo_wcpdf_after_document', $this->get_type(), $this->order ); ?>
62 changes: 35 additions & 27 deletions templates/Simple RTL/packing-slip.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
<?php do_action( 'wpo_wcpdf_before_document', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_document', $this->get_type(), $this->order ); ?>

<table class="head container">
<tr>
<td class="header">
<?php
if( $this->has_header_logo() ) {
if ( $this->has_header_logo() ) {
do_action( 'wpo_wcpdf_before_shop_logo', $this->get_type(), $this->order );
$this->header_logo();
do_action( 'wpo_wcpdf_after_shop_logo', $this->get_type(), $this->order );
} else {
echo $this->get_title();
}
?>
</td>
<td class="shop-info">
<?php do_action( 'wpo_wcpdf_before_shop_name', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_name', $this->get_type(), $this->order ); ?>
<div class="shop-name"><h3><?php $this->shop_name(); ?></h3></div>
<?php do_action( 'wpo_wcpdf_after_shop_name', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shop_name', $this->get_type(), $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shop_address', $this->get_type(), $this->order ); ?>
<div class="shop-address"><?php $this->shop_address(); ?></div>
<?php do_action( 'wpo_wcpdf_after_shop_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shop_address', $this->get_type(), $this->order ); ?>
</td>
</tr>
</table>

<?php do_action( 'wpo_wcpdf_before_document_label', $this->get_type(), $this->order ); ?>

<h1 class="document-type-label">
<?php if( $this->has_header_logo() ) echo $this->get_title(); ?>
<?php if ( $this->has_header_logo() ) echo $this->get_title(); ?>
</h1>

<?php do_action( 'wpo_wcpdf_after_document_label', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_document_label', $this->get_type(), $this->order ); ?>

<table class="order-data-addresses">
<tr>
<td class="address shipping-address">
<!-- <h3><?php _e( 'Shipping Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3> -->
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_shipping_address', $this->get_type(), $this->order ); ?>
<?php $this->shipping_address(); ?>
<?php do_action( 'wpo_wcpdf_after_shipping_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_shipping_address', $this->get_type(), $this->order ); ?>
<?php if ( isset($this->settings['display_email']) ) { ?>
<div class="billing-email"><?php $this->billing_email(); ?></div>
<?php } ?>
Expand All @@ -46,14 +50,14 @@
<td class="address billing-address">
<?php if ( !empty($this->settings['display_billing_address']) && ( $this->ships_to_different_address() || $this->settings['display_billing_address'] == 'always' ) ) { ?>
<h3><?php _e( 'Billing Address:', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_billing_address', $this->get_type(), $this->order ); ?>
<?php $this->billing_address(); ?>
<?php do_action( 'wpo_wcpdf_after_billing_address', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_billing_address', $this->get_type(), $this->order ); ?>
<?php } ?>
</td>
<td class="order-data">
<table>
<?php do_action( 'wpo_wcpdf_before_order_data', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_order_data', $this->get_type(), $this->order ); ?>
<tr class="order-number">
<th><?php _e( 'Order Number:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
<td><?php $this->order_number(); ?></td>
Expand All @@ -66,13 +70,13 @@
<th><?php _e( 'Shipping Method:', 'woocommerce-pdf-invoices-packing-slips' ); ?></th>
<td><?php $this->shipping_method(); ?></td>
</tr>
<?php do_action( 'wpo_wcpdf_after_order_data', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_order_data', $this->get_type(), $this->order ); ?>
</table>
</td>
</tr>
</table>

<?php do_action( 'wpo_wcpdf_before_order_details', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_order_details', $this->get_type(), $this->order ); ?>

<table class="order-details">
<thead>
Expand All @@ -83,11 +87,11 @@
</thead>
<tbody>
<?php $items = $this->get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item_id => $item ) : ?>
<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->type, $this->order, $item_id ); ?>">
<tr class="<?php echo apply_filters( 'wpo_wcpdf_item_row_class', $item_id, $this->get_type(), $this->order, $item_id ); ?>">
<td class="product">
<?php $description_label = __( 'Description', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
<span class="item-name"><?php echo $item['name']; ?></span>
<?php do_action( 'wpo_wcpdf_before_item_meta', $this->type, $item, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_item_meta', $this->get_type(), $item, $this->order ); ?>
<div class="item-meta"><?php echo $item['meta']; ?></div>
<ul class="meta">
<?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?>
Expand All @@ -98,31 +102,35 @@
<li class="weight"><strong class="weight-label"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></strong> <?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?></li>
<?php endif; ?>
</ul>
<?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_item_meta', $this->get_type(), $item, $this->order ); ?>
</td>
<td class="quantity"><?php echo $item['quantity']; ?></td>
</tr>
<?php endforeach; endif; ?>
</tbody>
</table>

<?php do_action( 'wpo_wcpdf_after_order_details', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_order_details', $this->get_type(), $this->order ); ?>

<?php do_action( 'wpo_wcpdf_before_customer_notes', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_before_customer_notes', $this->get_type(), $this->order ); ?>
<div class="customer-notes">
<?php if ( $this->get_shipping_notes() ) : ?>
<h3><?php _e( 'Customer Notes', 'woocommerce-pdf-invoices-packing-slips' ); ?></h3>
<?php $this->shipping_notes(); ?>
<?php endif; ?>
</div>
<?php do_action( 'wpo_wcpdf_after_customer_notes', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_customer_notes', $this->get_type(), $this->order ); ?>

<div class="bottom-spacer"></div>

<?php if ( $this->get_footer() ): ?>
<div id="footer">
<!-- hook available: wpo_wcpdf_before_footer -->
<?php $this->footer(); ?>
<!-- hook available: wpo_wcpdf_after_footer -->
</div><!-- #letter-footer -->
<htmlpagefooter name="docFooter">
<div id="footer">
<!-- hook available: wpo_wcpdf_before_footer -->
<?php $this->footer(); ?>
<!-- hook available: wpo_wcpdf_after_footer -->
</div><!-- #letter-footer -->
</htmlpagefooter>
<?php endif; ?>

<?php do_action( 'wpo_wcpdf_after_document', $this->type, $this->order ); ?>
<?php do_action( 'wpo_wcpdf_after_document', $this->get_type(), $this->order ); ?>
7 changes: 7 additions & 0 deletions templates/Simple RTL/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
margin-bottom: 3cm;
margin-left: 2cm;
margin-right: 2cm;
header: docHeader;
footer: docFooter;
}
body {
direction: rtl;
Expand Down Expand Up @@ -89,6 +91,11 @@ td.no-borders {
width: auto;
}

div.bottom-spacer {
clear: both;
height: 8mm;
}

/* Header */
table.head {
margin-bottom: 12mm;
Expand Down
Loading

0 comments on commit be22265

Please sign in to comment.