Created
October 14, 2022 04:50
-
-
Save pramodjodhani/3e3bea0dc09109fa1097423eb74044e7 to your computer and use it in GitHub Desktop.
Iconic WDS - add delivery date/time to Print Invoice & Delivery Notes for WooCommerce by Tyche Softwares
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
| <?php | |
| /** | |
| * Add delivery date and time to Print Invoice & Delivery Notes for WooCommerce by Tyche Softwares. | |
| * | |
| * @param array $fields | |
| * @param WC_Order $order | |
| * | |
| * @return array | |
| */ | |
| function iconic_add_invoice_fields( $fields, $order ) { | |
| $method = $order->get_shipping_method(); | |
| $label = false === strpos( $method, 'pickup' ) ? 'Delivery' : 'Pickup'; | |
| $delivery_date = $order->get_meta( 'jckwds_date' ); | |
| $delivery_time = $order->get_meta( 'jckwds_timeslot' ); | |
| if ( $delivery_date ) { | |
| $fields['iconic_wds_delivery_date'] = array( | |
| 'label' => $label . ' Date', | |
| 'value' => $delivery_date, | |
| ); | |
| } | |
| if ( $delivery_time ) { | |
| $fields['iconic_wds_delivery_time'] = array( | |
| 'label' => $label . ' Time', | |
| 'value' => $delivery_time, | |
| ); | |
| } | |
| return $fields; | |
| } | |
| add_filter( 'wcdn_order_info_fields', 'iconic_add_invoice_fields', 10, 2 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment