Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active June 1, 2023 07:53
Show Gist options
  • Select an option

  • Save hedqvist/7b053c95e446853f64a89f85dae1cc76 to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/7b053c95e446853f64a89f85dae1cc76 to your computer and use it in GitHub Desktop.
Add custom field to customer GUEST USERS
<?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