# Push notification (WooCommerce)

## 1. Admin Setup

### Step 1:  Enable Push Notifications

1. Navigate to **WebToNative Settings > Push** Notification in the WordPress admin dashboard.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeNj9Z7r73RTopJWP61-rWU1L-37ree5NjSzb4B_DeiYafi0C8cTJrH3QIM-QzdseVWVtrrCpcWIRbRMlNCJyZU9drBPX5dix1u4JMmzJcK2jHbOcHBVdxX45qSuTcsizIYJyIebQ?key=8fypB0WwX012kuShdOKyH1VA" alt="" width="375"><figcaption></figcaption></figure>

2. Enable the **"Enable Push Notification"** checkbox to activate push notifications

### Step 2:  Configure OneSignal Settings

1. Fill in the required fields:
   * **OneSignal App ID**: Enter your OneSignal application ID.
   * **REST API Key**: Enter the REST API key for your OneSignal account.

<figure><img src="https://46162361-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbRbEDU7JrvMAgg52AY%2Fuploads%2FPQRdYPiY02c3TVsFl3j2%2FScreenshot%202025-01-06%20at%2012.01.48%E2%80%AFPM.png?alt=media&#x26;token=9af2e7e5-2d3c-4465-a470-a7201bf9476e" alt=""><figcaption></figcaption></figure>

### Step 3:  Customize Order Status Messages

1. In the Customize Messages section:
   * Provide a **custom message** for each WooCommerce order status (e.g., "Processing," "Completed").
   * These messages will be sent to users as notifications when their order status changes.

### Step 4:  Save Settings

* Click Save Changes to apply the configuration.

## 2. Automatic Notifications for WooCommerce

* Push notifications are automatically triggered when a WooCommerce order status changes.
* The system:
  * Fetches the order details and user information.
  * Hashes the user ID with a secret key to generate an *<mark style="color:green;">**externalUserId**</mark>*.
  * Sends the custom message for the new order status via the OneSignal API.

## 3. Key Features

1. **Dynamic External User ID**: Ensures secure identification of users via hashed <mark style="color:green;">externalUserId</mark>.
2. **Customizable Notifications**: Allows custom messages for different WooCommerce order statuses.
3. **Automatic WooCommerce Event Handling**: Triggers notifications on order status changes.

## 4. Troubleshooting

* Notifications Not Sending?
  * Ensure push notifications are enabled in the settings.
  * Verify the OneSignal App ID and REST API Key.
  * Check that the wton\_notification\_key is properly set.
* Frontend Integration Issues?
  * Confirm the WTN.OneSignal object is available in the app environment.
  * Check the browser console for errors related to the script.


---

# 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://docs.webtonative.com/website-plugins/wordpress/push-notification-woocommerce.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.
