Last active
June 1, 2023 07:53
-
-
Save hedqvist/7b053c95e446853f64a89f85dae1cc76 to your computer and use it in GitHub Desktop.
Add custom field to customer GUEST USERS
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 | |
| /** | |
| * @snippet WooCommerce - Fortnox plugin by Redlight Media - (GUEST USERS) Set $our_custom_field as Comments on Customer | |
| * @author Redlight Media AB / Christopher Hedqvist | |
| * @compatible WooCommerce 3.4.2 | |
| */ | |
| function redlight_fortnox_guest_customer_data( $customer, $order_id ) { | |
| $order = wc_get_order( $order_id ); | |
| $our_custom_field = $order->get_meta('our_custom_field'); | |
| if(isset($our_custom_field)){ | |
| $customer['Customer']['Comments'] = $our_custom_field; | |
| } | |
| return $customer; | |
| } | |
| add_filter( 'obj_fortnox_guest_customer_data', 'redlight_fortnox_guest_customer_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment