• Resolved christianserramilano

    (@christianserramilano)


    Hi, I need to print a custom line on my pdf template if country is equal to something.
    How can I get this kind of data?
    On the invoice.php I can’t show how to get this data:

    Thank you!

    <?php if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly ?>
    <?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() ) {
    $this->header_logo();
    } else {
    echo $this->get_title();
    }
    ?>
    </td>
    <td class=”shop-info”>
    <div class=”shop-name”><h3><?php $this->shop_name(); ?></h3></div>
    <div class=”shop-address”><?php $this->shop_address(); ?></div>
    </td>
    </tr>
    </table>

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

    <?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 $this->billing_address(); ?>
    <?php do_action( ‘wpo_wcpdf_after_billing_address’, $this->type, $this->order ); ?>
    <?php if ( isset($this->settings[‘display_email’]) ) { ?>
    <div class=”billing-email”><?php $this->billing_email(); ?></div>
    <?php } ?>
    <?php if ( isset($this->settings[‘display_phone’]) ) { ?>
    <div class=”billing-phone”><?php $this->billing_phone(); ?></div>
    <?php } ?>
    </td>
    <td class=”address shipping-address”>
    <?php if ( isset($this->settings[‘display_shipping_address’]) && $this->ships_to_different_address()) { ?>
    <h3><?php _e( ‘Ship To:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></h3>
    <?php do_action( ‘wpo_wcpdf_before_shipping_address’, $this->type, $this->order ); ?>
    <?php $this->shipping_address(); ?>
    <?php do_action( ‘wpo_wcpdf_after_shipping_address’, $this->type, $this->order ); ?>
    <?php } ?>
    </td>
    <td class=”order-data”>
    <table>
    <?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 _e( ‘Invoice Number:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <td><?php $this->invoice_number(); ?></td>
    </tr>
    <?php } ?>
    <?php if ( isset($this->settings[‘display_date’])) { ?>
    <tr class=”invoice-date”>
    <th><?php _e( ‘Invoice Date:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <td><?php $this->invoice_date(); ?></td>
    </tr>
    <?php } ?>
    <tr class=”order-number”>
    <th><?php _e( ‘Order Number:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <td><?php $this->order_number(); ?></td>
    </tr>
    <tr class=”order-date”>
    <th><?php _e( ‘Order Date:’, ‘woocommerce-pdf-invoices-packing-slips’ ); ?></th>
    <td><?php $this->order_date(); ?></td>
    </tr>
    <tr class=”payment-method”>
    <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->get_type(), $this->order ); ?>
    </table>
    </td>
    </tr>
    </table>

    <?php do_action( ‘wpo_wcpdf_before_order_details’, $this->get_type(), $this->order ); ?>

    <table class=”order-details”>
    <thead>
    <?php if ( $headers = wpo_wcpdf_templates_get_table_headers( $this ) ): ?>
    <tr>
    <?php
    foreach ( $headers as $column_key => $header_data ) {
    printf(‘<th class=”%s”><span>%s</span></th>’, $header_data[‘class’], $header_data[‘title’]);
    }
    ?>
    </tr>
    <?php endif ?>
    </thead>
    <tbody>
    <?php
    $tbody = wpo_wcpdf_templates_get_table_body( $this );
    if( sizeof( $tbody ) > 0 ) {
    foreach( $tbody as $item_id => $item_columns ) {
    $row_class = apply_filters( ‘wpo_wcpdf_item_row_class’, $item_id, $this->get_type(), $this->order, $item_id );
    printf(‘<tr class=”%s”>’, $row_class);
    foreach ($item_columns as $column_key => $column_data) {
    printf(‘<td class=”%s”><span>%s</span></td>’, $column_data[‘class’], $column_data[‘data’]);
    }
    echo ‘</tr>’;
    }
    }
    ?>
    </tbody>
    </table>

    <table class=”notes-totals”>
    <tbody>
    <tr class=”no-borders”>
    <td class=”no-borders”>
    <?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->get_type(), $this->order ); ?>
    </td>
    <td class=”no-borders totals-cell” style=”width:40%”>
    <table class=”totals”>
    <tfoot>
    <?php
    $totals = wpo_wcpdf_templates_get_totals( $this );
    if( sizeof( $totals ) > 0 ) {
    foreach( $totals as $total_key => $total_data ) {
    ?>
    <tr class=”<?php echo $total_data[‘class’]; ?>”>
    <th class=”description”><span><?php echo $total_data[‘label’]; ?></span></th>
    <td class=”price”><span class=”totals-price”><?php echo $total_data[‘value’]; ?></span></td>
    </tr>
    <?php
    }
    }
    ?>
    </tfoot>
    </table>
    </td>
    </tr>
    </tbody>
    </table>

    <?php do_action( ‘wpo_wcpdf_after_order_details’, $this->get_type(), $this->order ); ?>

    <?php if ( $this->get_footer() ): ?>
    <div id=”footer”>
    <?php $this->footer(); ?>
    </div><!– #letter-footer –>
    <?php endif; ?>
    <?php do_action( ‘wpo_wcpdf_after_document’, $this->get_type(), $this->order ); ?>

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    You can get the country code (IT for Italy, FR for France, etc.) with $this->order->get_billing_country().

    or in an if statement:

    
    <?php if ( $this->order->get_billing_country() == 'IT' ) : ?>
    This line will only print for italian customers
    <?php endif; ?>
    
Viewing 1 replies (of 1 total)
  • The topic ‘IF country ELSE on pdf template’ is closed to new replies.