<?php
/**
 * Email Addresses
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-addresses.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see 	    https://docs.woocommerce.com/document/template-structure/
 * @author 		WooThemes
 * @package 	WooCommerce/Templates/Emails
 * @version     3.2.1
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$text_align = is_rtl() ? 'right' : 'left';

?>
<hr style="visibility: hidden;" />
<table id="addresses" cellspacing="0" cellpadding="0" style="width: 45%; vertical-align: top; margin-bottom: 40px; padding:0; float: left;" border="0">
	<tr>
            <td style="text-align:<?php echo $text_align; ?>;  background: #333; color: #fff;">
                <h2 style="color: #fff;"><?php _e( 'Rechnungsinformation', 'woocommerce' ); ?></h2><!-- billing address address-->
            </td>
        </tr>
        <tr>
            <td style="color: #333; background: #fff;">
                <address class="">
                        <?php echo ( $address = $order->get_formatted_billing_address() ) ? $address : __( 'N/A', 'woocommerce' ); ?>
                        <?php if ( $order->get_billing_phone() ) : ?>
                                <br/><?php echo esc_html( $order->get_billing_phone() ); ?>
                        <?php endif; ?>
                        <?php if ( $order->get_billing_email() ) : ?>
                                <p><?php echo esc_html( $order->get_billing_email() ); ?></p>
                        <?php endif; ?>
                </address>
            </td>
        </tr>
</table>
<table cellspacing="0" cellpadding="0" style="width: 45%; vertical-align: top; margin-bottom: 40px; padding:0; float: right;" border="0">
    <tr>
        <td style="background: #333333; color: #fff;">
            <h2 style="color: #fff;"><?php _e( 'Zahlart', 'woocommerce' ); ?></h2>

        </td>

    </tr>
    <tr>
        <td style="background: #fff; color: #333;">
            <p><?php echo $order->get_payment_method(); ?></p>
            <?php
            $paymentID = get_post_meta( $order->get_id(),  '_transaction_id', true );
            if ( !empty( $paymentID ) ) { ?>
                <p><?php _e( 'PAYMENT ID:', 'erfolg' ); ?><?php echo $paymentID;?></p>
            <?php } ?>
        </td>
    </tr>
</table>

<hr style="visibility: hidden; display: block; clear: both; width: 100%;" />


    <table cellspacing="0" cellpadding="0" style="width: 45%; vertical-align: top; margin-bottom: 40px; padding:0; float: left;" border="0">
        <tr>
            <?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
                <td style="text-align:<?php echo $text_align; ?>; background: #333;" >
                        <h2 style="color: #fff;"><?php _e( 'Versandinformation', 'woocommerce' ); ?></h2><!-- shipping address-->

                </td>
            </tr>
            <tr>

            <td style="color: #333; background: #fff;">
                <address class=""><?php echo $shipping; ?></address>
            </td>
            <?php endif; ?>
        </tr>
    </table>
    <table cellspacing="0" cellpadding="0" style="width: 45%; vertical-align: top; margin-bottom: 40px; padding:0; float: right;" border="0">
        <tr>
            <td style="background: #333; color: #fff;">
                <h2 style="color: #fff;"><?php _e( 'Versandart', 'woocommerce' ); ?></h2>

            </td>
        </tr>
        <tr>
            <td style="background: #fff; color: #333;">
                <?php
                foreach( $order->get_items( 'shipping' ) as $item_id => $shipping_item_obj ){
                    // Get the data in an unprotected array
                    $shipping_item_data = $shipping_item_obj->get_data();

                    $shipping_data_id           = $shipping_item_data['id'];
                    $shipping_data_order_id     = $shipping_item_data['order_id'];
                    $shipping_data_name         = $shipping_item_data['name'];
                    $shipping_data_method_title = $shipping_item_data['method_title'];

                }
                echo '<p>' . $shipping_data_method_title .  '</p>'; ?>
            </td>
        </tr>
    </table>
