Here you go!
p.s. there might be a better way, but this works well too! 😉
<?php
$billing_first_name = get_post_meta($wpo_wcpdf->export->order->id,'_billing_first_name',true);
$billing_last_name = get_post_meta($wpo_wcpdf->export->order->id,'_billing_last_name',true);
$billing_company = get_post_meta($wpo_wcpdf->export->order->id,'_billing_company',true);
$billing_address = get_post_meta($wpo_wcpdf->export->order->id,'_billing_address_1',true);
$billing_address2 = get_post_meta($wpo_wcpdf->export->order->id,'_billing_address_2',true);
$billing_city = get_post_meta($wpo_wcpdf->export->order->id,'_billing_city',true);
$billing_postcode = get_post_meta($wpo_wcpdf->export->order->id,'_billing_postcode',true);
$billing_country = get_post_meta($wpo_wcpdf->export->order->id,'_billing_country',true);
$billing_state = get_post_meta($wpo_wcpdf->export->order->id,'_billing_state',true);
$billing_email = get_post_meta($wpo_wcpdf->export->order->id,'_billing_email',true);
$billing_phone = get_post_meta($wpo_wcpdf->export->order->id,'_billing_phone',true);
$billing_paymethod = get_post_meta($wpo_wcpdf->export->order->id,'_payment_method',true);
?>
<?php echo $billing_first_name; ?>
<?php echo $billing_last_name; ?>
<?php echo $billing_company; ?>
<?php echo $billing_address; ?>
<?php echo $billing_city; ?>
<?php echo $billing_postcode; ?>
<?php echo $billing_country; ?>
<?php echo $billing_state; ?>
<?php echo $billing_email; ?>
<?php echo $billing_phone; ?>
<?php echo $billing_paymethod; ?>
whoa, thanks mane. exactly what I needed 🙂
Plugin Contributor
Ewout
(@pomegranate)
Thanks for helping out @gxt!
Alternatively you can just echo the get_post_meta straight like this:
<?php echo get_post_meta($wpo_wcpdf->export->order->id,'_billing_first_name',true); ?>
Note that email, phone, shipping- & payment method already have their own function calls:
<?php $wpo_wcpdf->billing_email(); ?>
<?php $wpo_wcpdf->billing_phone(); ?>
<?php $wpo_wcpdf->payment_method(); ?>
<?php $wpo_wcpdf->shipping_method(); ?>
I’m definitely doing that. seem much cleaner and faster 😀 Thanks Ewout!
Plugin Contributor
Ewout
(@pomegranate)
Hi Aristotele,
One more tip for you:
The country and state values will contain the short forms (GB, DE, US etc.). To get the full names you will need to pull them from woocommerce like this:
$countries = new WC_Countries;
$billing_country = get_post_meta($wpo_wcpdf->export->order->id,'_billing_country',true);
$billing_state = get_post_meta($wpo_wcpdf->export->order->id,'_billing_state',true);
$billing_state_full = ( $billing_country && $billing_state && isset( $countries->states[ $billing_country ][ $billing_state ] ) ) ? $countries->states[ $billing_country ][ $billing_state ] : $billing_state;
$billing_country_full = ( $billing_country && isset( $countries->countries[ $billing_country ] ) ) ? $countries->countries[ $billing_country : $billing_country;
// clear the $countries object when we're done to free up memory
unset($countries);
Plugin Contributor
Ewout
(@pomegranate)
There is an error in the code from my last post above (missing square bracket), the code to display the billing country should be:
<?php
$countries = new WC_Countries;
$billing_country = get_post_meta($wpo_wcpdf->export->order->id,'_billing_country',true);
$billing_state = get_post_meta($wpo_wcpdf->export->order->id,'_billing_state',true);
$billing_state_full = ( $billing_country && $billing_state && isset( $countries->states[ $billing_country ][ $billing_state ] ) ) ? $countries->states[ $billing_country ][ $billing_state ] : $billing_state;
$billing_country_full = ( $billing_country && isset( $countries->countries[ $billing_country ] ) ) ? $countries->countries[ $billing_country ] : $billing_country;
// clear the $countries object when we're done to free up memory
unset($countries);
echo $billing_country_full;
?>