This plugin will track sales made by Partner Ads affiliates.
It works by saving the affiliate partner id when the visitor visits any page on your shop. Then when the user successfully completes an order it will send a HTTP request to Partner Ads telling them to credit the affiliate partner.
composer require setono/sylius-partner-ads-pluginThen, enable the plugin by adding it to the list of registered plugins/bundles
in the config/bundles.php file of your project before (!) SyliusGridBundle:
<?php
# config/bundles.php
return [
Setono\SyliusPartnerAdsPlugin\SetonoSyliusPartnerAdsPlugin::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
];# config/packages/_sylius.yaml
imports:
# ...
- { resource: "@SetonoSyliusPartnerAdsPlugin/Resources/config/app/config.yaml" }
# ...# config/routes/setono_sylius_partner_ads.yaml
setono_partner_ads_plugin:
resource: "@SetonoSyliusPartnerAdsPlugin/Resources/config/routing.yaml"If you already use a PSR18 HTTP client you need to inject that service:
setono_sylius_partner_ads:
http_client: '@http_client_service_id'If not, you can just do composer the Buzz library and it will automatically register the Buzz client as the HTTP client:
$ composer require kriswallsmith/buzz$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrateLogin to your Sylius app admin and go to the Partner Ads page and click "Create" to create a new program. Fill in the program id of your Partner Ads program, make sure "enable" is toggled on, and choose which channel the program should be applied to. Please notice you should only make one program for each channel, or else you will end up with undefined behaviour.
This plugin will make a HTTP request to Partner Ads when a customer completes an order. This will make the 'Thank you' page load slower. To circumvent that you can use RabbitMQ with Symfony Messenger to send this HTTP request asynchronously.
Follow the installation instructions here: How to Use the Messenger and then configure a transport.
Basically you should do:
$ composer req messenger symfony/serializer-packThen configure the Messenger component:
# config/packages/messenger.yaml
framework:
messenger:
transports:
amqp: "%env(MESSENGER_TRANSPORT_DSN)%"# .env
###> symfony/messenger ###
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
###< symfony/messenger ###And finally configure the plugin to use your transport:
setono_sylius_partner_ads:
messenger:
transport: amqpAfter this the Messenger will be automatically enabled in this plugin and subsequently it will send an asynchronous request to Partner Ads instead of a synchronous.
For testing purposes you can sign up for a free RabbitMQ cloud service here: CloudAMQP.