# 12.2 Action Hook: lcw\_update\_product\_meta

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

it can be done in 2 ways,

1. add product 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 product 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_product_meta

add_action("lcw_update_product_meta", "lcw_update_product_meta_function", 10, 3);
function lcw_update_product_meta_function($product, $product_id, $contact_id){
    
    // You will get here $product & $product_id
    // With the product_id, you can retrieve your product metadata
    
    // 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 );

};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://better-wizard.gitbook.io/lead-connector-wizard/deloper-resources/12.2-action-hook-lcw_update_product_meta.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
