# Magento 2

{% hint style="success" %}
For Magento `2.4.6+`, please use version `2.4.24` of the plugin or later.\
For previous versions of Magento, please use version `2.4.21` of the plugin.
{% endhint %}

## Installation and Setup Guide

{% hint style="danger" %}
If you have [Mageplaza Webhook](https://www.mageplaza.com/magento-2-webhook/) already installed, **DO NOT INSTALL** this extension and follow our setup guide instead: [<mark style="color:blue;">Setup Guide with Mageplaza Webhook</mark>](https://github.com/parcelLab/magento-2-webhook/blob/2.4.24/setup-guide-with-mageplaza.md)
{% endhint %}

To install the Magento 2 Webhook extension:

1. Run the following command in Magento 2 root folder:

```
composer require parcellab/magento-2-webhook
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
```

2. After successful installation and deploy log in to your Admin Backend of Magento, navigate to `System > parcelLab Webhook > Configuration`.<br>

   <div align="left"><figure><img src="/files/mLR9vHogPyC2EOGAKulm" alt="" width="351"><figcaption></figcaption></figure></div>

   In this screen, you will have to enter your parcelLab API credentials.
3. Generate a new **parcelLab API Token** with `write` access in the parcelLab Portal.
4. Enter the newly generated **parcelLab API Token** together with your **parcelLab User ID.**<br>

   <div align="left"><figure><img src="/files/XgTBEcIUVxEeXH7KWXHb" alt=""><figcaption></figcaption></figure></div>

   When entering your credentials:

   * Use your **parcelLab User ID**, not an email address.
   * Use the plain **API token** value from parcelLab. Do not use an encoded or encrypted token.
   * In the same screen, set **Enabled** to **Yes**. This setting is separate from the event configuration and must also be enabled.
   * Save the configuration and flush the Magento cache before testing.

{% hint style="warning" %}
The plugin must be enabled in `System > parcelLab Webhook > Configuration` in addition to enabling the events in `Manage Events`. If `Enabled` remains `No`, the events can still appear active, but the webhook request body will not be sent to parcelLab.
{% endhint %}

5. Navigate to `System > parcelLab Webhook > Manage Events`.<br>

   <div align="left"><figure><img src="/files/wy0tZmBL7qLsWqByzopI" alt="" width="355"><figcaption></figcaption></figure></div>

   \
   You will find the two required events already pre-configured.<br>

   <div align="left"><figure><img src="/files/Wsxm6hQEtNa4rjDVKTw2" alt="" width="563"><figcaption></figcaption></figure></div>
6. If you have entered your parcelLab credentials earlier and set the plugin configuration to **Enabled = Yes**, activate the events.<br>

   <figure><img src="/files/TbBrutqw8sCMBNKk1SvB" alt=""><figcaption></figcaption></figure>
7. After saving any configuration or event changes, flush the Magento cache and place a new test order to confirm the webhook is sent successfully.

🎉 **Your integration is complete!** 🎉

<div align="left"><figure><img src="/files/Finn5rBHTm272RBK6Eg5" alt="" width="563"><figcaption></figcaption></figure></div>

## FAQs

<details>

<summary>Can I add more events?</summary>

Due to the tailored use of this extension, the number of events is limited. For more flexible webhooks please use the fork source [Magento 2 Webhook by Mageplaza](https://www.mageplaza.com/magento-2-webhook/).

</details>

<details>

<summary>I received the error <code>Mageplaza_Core has been already defined</code></summary>

You can resolve it by following the solution [here](https://github.com/mageplaza/module-core/issues/3).

</details>

<details>

<summary>My site is down, what should I do?</summary>

You can resolve it by following [this guide](https://www.mageplaza.com/blog/magento-site-down.html).

</details>

<details>

<summary>Where do I find transfer logs?</summary>

Navigate to `System > parcelLab Webhook > Transfer Logs.`

![image](https://user-images.githubusercontent.com/625618/201497376-016e840b-2885-4029-8143-e1b7da291ba9.png)

The transfer logs will display a list of recent transfers and you can view the details for each entry by selecting **View** in the **Action** column.

<img src="/files/DbsGkfZAcE9ishH6uC0P" alt="image" data-size="original">

When requesting support, please share both the `Response` as well as the `Request Body`.

![image](/files/rUIVmICwPp7qNmu4wnDg)

</details>

<details>

<summary>The events are enabled, but parcelLab is not receiving the webhook or the request body is blank</summary>

Check the following in Magento:

* In `System > parcelLab Webhook > Configuration`, set **Enabled** to **Yes**.
* Enter your **parcelLab User ID** and make sure it is not replaced with an email address.
* Use the plain **API token** value from parcelLab, not an encoded or encrypted token.
* Flush the Magento cache after saving configuration changes.

If `Enabled` is set to `No`, the events can still appear active in `Manage Events`, but the webhook payload will not be sent to parcelLab.

</details>

<details>

<summary>I am unsure whether I have Magento 2 Webhook by Mageplaza installed, how can I check?</summary>

Run `php bin/magento module:status` and check whether `Mageplaza_Webhook` is listed.

If it is listed, please do not install this extension and follow our [Setup Guide with Mageplaza Webhook](https://github.com/parcelLab/magento-2-webhook/blob/2.4.24/setup-guide-with-mageplaza.md) instead.

</details>

<details>

<summary>If I already have Magento 2 Webhook by Mageplaza installed, how can I integrate with parcelLab?</summary>

The easiest way is to follow our [Setup Guide with Mageplaza Webhook](https://github.com/parcelLab/magento-2-webhook/blob/2.4.24/setup-guide-with-mageplaza.md) for this extension, which will take you less than 15 minutes to complete.

</details>

## Credit

{% hint style="info" %}
This extension is a fork of the [<mark style="color:blue;">Magento 2 Webhook by Mageplaza</mark>](https://www.mageplaza.com/magento-2-webhook/) published under MIT license [<mark style="color:blue;">on Github</mark>](https://github.com/mageplaza/magento-2-webhook) (see fork source). This fork simplifies your setup for integration with parcelLab by providing appropriate defaults.
{% endhint %}

It also uses the following packages:

* [mageplaza/module-core](https://packagist.org/packages/mageplaza/module-core)
* [liquid/liquid](https://packagist.org/packages/liquid/liquid)


---

# 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.parcellab.com/docs/platform/app-store/magento-2.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.
