> For the complete documentation index, see [llms.txt](https://better-wizard.gitbook.io/lead-connector-wizard/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://better-wizard.gitbook.io/lead-connector-wizard/deloper-resources/action-hook-lcw-update-order-meta.md).

# 12.1 Action Hook: lcw\_update\_order\_meta

By this action hook, you can add order metadata to GHL. this hook provides 3 parameters\
\
a). $order\
b). $order\_id\
c). $contact\_id (GHL contact id)

it can be done in 2 ways,

1. add order metadata to the contact custom field: to do this you need to use a function lcw\_update\_contact\_fields() where you need to pass an array of your custom field keys with respective values. example:

   ```
   $fields = array(
    	'new_custom_field_key' => "Test value.." // the GHL keys are {{contact.new_custom_field_key}}
   );

   lcw_update_contact_fields( $contact_id, $fields );
   ```
2. add order metadata as a note: to do this you also need to use a function lcw\_create\_contact\_note() where you need to pass the note to add to the contact.<br>

   ```
   $note = "This is a new note!";
   lcw_create_contact_note( $contact_id, $note );
   ```

To implement this hook let's see an example:

```
// How to use action hook: lcw_update_order_meta

add_action("lcw_update_order_meta", "lcw_sync_order_meta_function", 10, 3);
function lcw_sync_order_meta_function($order, $order_id, $contact_id){
    
    // You will get here $order & $order_id
    // With the order_id, you can retrieve your order meta data
    
    // Add to custom field
    // Arrange the order meta data in an array as key => value pair, 

    $fields = array(
 	'new_custom_field_key' => "Test value.." // the GHL keys are {{contact.new_custom_field_key}}
    );
    
    // Run the function
    lcw_update_contact_fields( $contact_id, $fields );
    
    // Add as a contact note
    $note = "This is a new note!";
    lcw_create_contact_note( $contact_id, $note );

};
```
