Get shipping country in invoice template
-
Hi,
I’m trying to display different value on my invoice depending on the order shipping country.
I have tried to add :
$country = $this->get_shipping_country();inside my template but its work only when this modified piece of code is added :public function get_shipping_country() { // always prefer parent shipping country for refunds if ( $this->is_refund( $this->order ) ) { // temporarily switch order to make all filters / order calls work correctly $refund = $this->order; $this->order = $this->get_refund_parent( $this->order ); $country = apply_filters( 'wpo_wcpdf_shipping_country', $this->order->get_shipping_country(), $this ); // switch back & unset $this->order = $refund; unset($refund); } elseif ( $country = $this->order->get_shipping_country() ) { // regular shop_order $country = apply_filters( 'wpo_wcpdf_shipping_country', $country, $this ); } else { // no address // use fallback for packing slip if ( apply_filters( 'wpo_wcpdf_shipping_country_fallback', ( $this->get_type() == 'packing-slip' ), $this ) ) { $country = $this->get_billing_country(); } else{ $country = apply_filters( 'wpo_wcpdf_shipping_country', __('N/A', 'woocommerce-pdf-invoices-packing-slips' ), $this ); } } return $country; } public function shipping_country() { echo $this->get_shipping_country(); }My issue is that I need to put this code inside woocommerce-pdf-invoices-packing-slips/includes/documents/abstract-wcpdf-order-document-methods.php file otherwise it do not work. So of course it’s overridden every update.
So how can I achieve to make works
$country = $this->get_shipping_country();in my invoice template by adding a piece of code inside template-functions.php ?Thanks for your help,
Best Regards.
The topic ‘Get shipping country in invoice template’ is closed to new replies.