Skip to content

Commit

Permalink
Update docs (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Apr 26, 2022
1 parent 328cfb5 commit 34183b5
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/02-Installation.md
Expand Up @@ -129,7 +129,7 @@
}
```
If you have added the ChannelCustomer entity be sure to mark it as a Sylius Resource by adding the following lines in
the
the `webgriffe_sylius_active_campaign_plugin.yaml` file:

```yaml
webgriffe_sylius_active_campaign:
Expand Down
46 changes: 31 additions & 15 deletions docs/03-Usage.md
Expand Up @@ -47,11 +47,12 @@ same `email`.

#### Contact tags

By creating or updating a contact you will probably have to add some tags to this contact. If this is your case there is
nothing to more simple than add this tags to your contact 😀. After the creating or the update of a contact a new
To complete your contact you will probably have to add some tags to this contact. If this is your case there is
nothing to more simple than add this tags to your contact 😀. After the creation or the update of a Sylius customer a
new
Message `ContactTagsAdder` will be dispatched to the messenger bus. The `ContactTagsAdderHandler` will use
the `webgriffe.sylius_active_campaign_plugin.resolver.contact_tags`
service to resolve a list of tags to add to the contact. By default this service will return an empty list, but you can
service to resolve a list of tags to add to the contact. By default, this service will return an empty list, but you can
customize it by overriding this service and by making it implements
the `Webgriffe\SyliusActiveCampaignPlugin\Resolver\ContactTagsResolverInterface`. The more beautiful thing is that you
don't have to worry about retrieve the ActiveCampaign tag's id, the plugin will do it for you 🎉. You just have to
Expand All @@ -77,7 +78,7 @@ contact to a list.

![Channel list ID form](images/edit_channel_list_id_form.png "Channel list ID form")

With the create/update contact handler a new `ContactListsSubscriber` message is dispatched.
With the create/update of a Sylius customer a new `ContactListsSubscriber` message is dispatched.
The `ContactListsSubscriberHandler` will then use the `CustomerChannelsResolver` to determine the channels for which a
contact list subscription should be created or updated. Then each channel will check if a list id is provided, if not it
will skip that channel. Then the `ListSubscriptionStatusResolverInterface` service is called. This service is
Expand Down Expand Up @@ -122,19 +123,16 @@ If you have enabled the contact list subscription feature it could be probably t
ActiveCampaign if this state change on this system. Let's make an example: The customer have subscribed to the
newsletter, so it has been subscribed to a contact's list. But, after a while, the customer chooses to unsubscribe from
this list thanks to the email link. When the customer make some update to his data or when a new contact update is
dispatched the contact will be subscribed again in the list if the subscription status is not touched. This will cause a
problem for you contact and your image. In order to prevent this we have thought to use the ActiveCampaign's webhook
dispatched, the contact will be subscribed again in the list if the subscription status is not touched. This will cause
a
problem for you contact and your business image. In order to prevent this we have thought to use the ActiveCampaign's
webhook
functionality to receive the new list status subscription.
First of all, if you have skipped the app_routes step in the installation you should add this route to your application.
First, if you have skipped the `app_routes` step in the installation you should add this route to your application.
Then, you should add the webhook on ActiveCampaign. Of course, you could add the webhook manually from the app
dashboard, but we have prepared a command to add it directly from your Sylius store.
dashboard, but we have prepared a command to add it directly from your Sylius store, check
the [First setup docs](03_A-First_setup.md) on how to launch this command.

```shell
php bin/console webgriffe:active-campaign:enqueue-webhook --all
```

This command will create the webhook for all the channels that have an ActiveCampaign list id not nullable. You can also
launch the previous command with argument the id of the channel for which create a list status update webhook.
When the webhook comes from ActiveCampaign a new ContactListsUpdater message is dispatched to the bus.
Then the ContactListsUpdaterHandler will catch this message and make an HTTP get request to retrieve the updated contact
from ActiveCampaign. Now, as for the subscriber, there are two possibilities to update the status of the list
Expand All @@ -153,7 +151,9 @@ subscription that both implement the
the `webgriffe.sylius_active_campaign_plugin.updater.channel_customer_based_list_subscription_status`
with `webgriffe.sylius_active_campaign_plugin.updater.customer_based_list_subscription_status`.

**NOTE!** If you use the customer's isSubscribedToNewsletter property and you have more than one list you probably have to customize the StatusUpdater service to update the status only if the status comes from a certain list or by others logic.
**NOTE!** If you use the customer's isSubscribedToNewsletter property, and you have more than one list you probably have
to customize the StatusUpdater service to update the status only if the status comes from a certain list or by others
logic.

### Connection

Expand All @@ -180,6 +180,22 @@ customer with the same `email` and `connectionid` (the channel's code).
The ActiveCampaign's Ecommerce Order is the equivalent of the Sylius Order. In addition, as done on Sylius, The
Abandoned Cart is the same entity as the Ecommerce Order, so also the Abandoned Cart is related to the Sylius Order.

But what if you need to export to ActiveCampaign only some Sylius Orders? Simply, just override the logic inside the
`findAllToEnqueue` `OrderRepository`'s method. So, you can, for example, exports only orders by some customers.

The EcommerceOrderProductMapper service set the product image url needed to show it in the ActiveCampaign admin
dashboard but also for the email template. By default, the service will take the first image for the product, but you can
specify a Sylius image type to use for this purpose (for example you could have a `main` type used to specify the first
image of the product). Set this parameter in the `webgriffe_sylius_active_campaign_plugin.yaml` file:

```yaml
webgriffe_sylius_active_campaign:
...
mapper:
ecommerce_order_product:
image_type: 'main'
```

Before creating the resource on ActiveCampaign, the EcommerceOrderEnqueuer queries for a corresponding ecommerce order
with the same `email` and `externalid` (the order's id)/`externalcheckoutid` (the cart's id) based on the state of the
order (cart or different).
Expand Down
70 changes: 52 additions & 18 deletions docs/03_A-First_setup.md
Expand Up @@ -4,8 +4,8 @@

Right after installing the plugin, you need to export all the resources to ActiveCampaign if you start from scratch,
persist the ActiveCampaign resource's id on Sylius resource if you already have ActiveCampaign populated, and/or of
course, create and associate at the same time if you start from a mixed case. To do this the plugin offers three
commands to do this.
course, create and associate at the same time if you start from a mixed case. To do this the plugin offers different
commands to reach this scope.

### The Enqueue Connection Command

Expand Down Expand Up @@ -34,6 +34,20 @@ You can also launch the command without any arguments, it will ask you automatic
php bin/console webgriffe:active-campaign:enqueue-connection
```

### The Enqueue Webhook Command

If you want to maintain updated the list subscriptions status of you customers on Sylius you should enable a webhook for the updates of these subscriptions on ActiveCampaign.
You could obviously create the webhook manually from the AC's dashboard, but you can also use our command:

```shell
php bin/console webgriffe:active-campaign:enqueue-webhook --all
```

This command will create the webhook for all the channels that have an ActiveCampaign list id not nullable. You can also
launch the previous command with argument the id of the channel for which create a list status update webhook.

> **NOTE!** Be sure to add the `webgriffe_sylius_active_campaign_list_status_webhook` route to your app before launch this command, otherwise the route to call from the webhook could not be resolved.
### The Enqueue Contact and Ecommerce Customer Command

The Enqueue Contact and Ecommerce Customer Command creates/updates the Sylius Customer as Contacts and Ecommerce
Expand Down Expand Up @@ -83,6 +97,42 @@ You can also launch the command without any arguments, it will ask you automatic
php bin/console webgriffe:active-campaign:enqueue-contact-and-ecommerce-customer
```

### The Enqueue Contact Tags Adder Command

If you start from scratch with ActiveCampaign it is probably that you need to add some tags to all of your customers/contacts.
You can use the Enqueue Contact Tags Adder Command to reach this scope:

```shell
php bin/console webgriffe:active-campaign:enqueue-contact-tags-adder --all
```

This command will enqueue to add tags to all the ActiveCampaign's enabled customers of you app. You can also
launch the previous command with argument the id of the customer for which add the tags.

### The Enqueue Contact Lists Subscription Command

If you start from scratch with ActiveCampaign it is probably that you want to subscribe massively all your customers/contacts to the properly Channel's lists.
You can use the Enqueue Contact Lists Subscription Command to reach this scope:

```shell
php bin/console webgriffe:active-campaign:enqueue-contact-lists-subscription --all
```

This command will enqueue all contact lists subscription for all the customers enabled to export them on ActiveCampaign. You can also
launch the previous command with argument the id of the customer for which subscribe to lists.

### The Update Contact Lists Subscription Command

Alternatively to the previous command, if you start from an already populated status on ActiveCampaign, it is probably that you want to update massively all your customers/contacts subscription to Channel's lists on you Sylius store.
This will avoid subscribe to a list when not explicitly requested. You can use the Update Contact Lists Subscription Command to reach this scope:

```shell
php bin/console webgriffe:active-campaign:update-contact-lists-subscription --all
```

This command will update all contact lists subscription for all the customers enabled to export them on ActiveCampaign. You can also
launch the previous command with argument the id of the customer for which update subscription to lists.

### The Enqueue Ecommerce Order Command

The Enqueue Ecommerce Order Command creates/updates the Sylius Orders/Carts as Ecommerce Order/Abandoned Cart on
Expand All @@ -97,22 +147,6 @@ creates the orders and carts without the "source" flag enabled. This means that
orders wouldn't start. This is probably what is right for you since it is a historian of orders, but you can customize
it.

But what if you need to export to ActiveCampaign only some Sylius Orders? Simply, just override the logic inside the
`findAllToEnqueue` `OrderRepository`'s method. So, you can, for example, exports only orders by some customers.

The EcommerceOrderProductMapper service set the product image url needed to show it in the ActiveCampaign admin
dashboard but also for the email template. By default, the service will take the first image for the product, but you can
specify a Sylius image type to use for this purpose (for example you could have a `main` type used to specify the first
image of the product). Set this parameter in the `webgriffe_sylius_active_campaign_plugin.yaml` file:

```yaml
webgriffe_sylius_active_campaign:
...
mapper:
ecommerce_order_product:
image_type: 'main'
```

Also, remember that this command acts like a "create/update ecommerce order on ActiveCampaign" so, if you added an
order, not from the shop checkout you could launch it without any fear, and it will enqueue the new ecommerce order
creation. The command offers also a way to specify which order/cart enqueue by adding the order-id parameter to it:
Expand Down
4 changes: 2 additions & 2 deletions docs/03_B-Events.md
Expand Up @@ -24,8 +24,8 @@ The plugin listen for these customer events:
- `sylius.customer.post_update`
- `sylius.customer.post_delete`

The first three will lead to a Contact/Ecommerce Customer Create/Update. The last one will lead to a
Contact/EcommerceCustomer Remove.
The first three will lead to a Contact/Ecommerce Customer Create/Update, a ContactTagsAdder and a
ContactListsSubscriber. The last one will lead to a Contact/EcommerceCustomer Remove.

### Ecommerce Order events

Expand Down

0 comments on commit 34183b5

Please sign in to comment.