Created
February 13, 2020 06:13
-
-
Save webtoffee-git/680db9ad164b3efdb3c75f461bbf9069 to your computer and use it in GitHub Desktop.
Change shipping From address to ship To address using - - WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('wf_alter_shipping_from_address','wt_alter_shipping_from_address',10, 3); | |
| function wt_alter_shipping_from_address($address, $document_type, $order){ | |
| if($document_type=='dispatchlabel'){ | |
| $order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id(); | |
| $fromaddress = array(); | |
| $countries = new WC_Countries; | |
| $shipping_country = get_post_meta($order_id, '_shipping_country', true); | |
| $shipping_state = get_post_meta($order_id, '_shipping_state', true); | |
| $shipping_state_full = ( $shipping_country && $shipping_state && isset($countries->states[$shipping_country][$shipping_state]) ) ? $countries->states[$shipping_country][$shipping_state] : $shipping_state; | |
| $shipping_country_full = ( $shipping_country && isset($countries->countries[$shipping_country]) ) ? $countries->countries[$shipping_country] : $shipping_country; | |
| $fromaddress['sender_name'] = $order->shipping_first_name.' '.$order->shipping_last_name; | |
| $fromaddress['sender_address_line1'] = $order->shipping_address_1; | |
| $fromaddress['sender_address_line2'] = $order->shipping_address_2; | |
| $fromaddress['sender_city'] = $order->shipping_city; | |
| $fromaddress['sender_state'] = get_option('woocommerce_wf_state_code_disable') != '' && get_option('woocommerce_wf_state_code_disable') === 'yes' ? $shipping_state_full : $shipping_state; | |
| $fromaddress['sender_country'] = $shipping_country_full; | |
| $fromaddress['sender_postalcode'] = $order->shipping_postcode; | |
| return $fromaddress; | |
| } | |
| return $address; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment