setono / sylius-partner-ads-plugin
Sylius plugin that integrates Partner Ads tracking.
Installs: 39 429
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 3
Open Issues: 7
Type:sylius-plugin
Requires
- php: >=7.4
- ext-mbstring: *
- knplabs/knp-menu: ^3.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- sylius/resource-bundle: ^1.6
- symfony/config: ^5.4 || ^6.0
- symfony/dependency-injection: ^5.4 || ^6.0
- symfony/event-dispatcher: ^5.4 || ^6.0
- symfony/form: ^5.4 || ^6.0
- symfony/http-foundation: ^5.4 || ^6.0
- symfony/http-kernel: ^5.4 || ^6.0
- symfony/messenger: ^5.4 || ^6.0
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/core: ^2.7
- friendsofsymfony/oauth-server-bundle: >2.0.0-alpha.0 ^2.0@dev
- kriswallsmith/buzz: ^1.2
- lexik/jwt-authentication-bundle: ^2.16
- matthiasnoback/symfony-config-test: ^4.3
- matthiasnoback/symfony-dependency-injection-test: ^4.3
- phpspec/phpspec: ^7.2
- phpunit/phpunit: ^9.5
- psalm/plugin-symfony: ^5.0
- setono/code-quality-pack: ^2.2
- sylius/admin-api-bundle: ^1.11
- sylius/sylius: ~1.10.14
- symfony/debug-bundle: ^5.4 || ^6.0
- symfony/dotenv: ^5.4 || ^6.0
- symfony/intl: ^5.4 || ^6.0
- symfony/serializer-pack: ^1.0
- symfony/web-profiler-bundle: ^5.4 || ^6.0
- symfony/webpack-encore-bundle: ^1.15
- 3.x-dev
- 2.x-dev
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.0
- v2.0.0-alpha
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- dev-dependabot/composer/lexik/jwt-authentication-bundle-tw-2.18
- dev-dependabot/composer/phpunit/phpunit-tw-9.6
- dev-dependabot/composer/setono/code-quality-pack-tw-2.4
- dev-dependabot/composer/phpspec/phpspec-tw-7.3
- dev-dependabot/composer/psalm/plugin-symfony-tw-5.0
- dev-rewrite
This package is auto-updated.
Last update: 2024-12-19 14:38:54 UTC
README
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.
Installation
Step 1: Download the plugin
composer require setono/sylius-partner-ads-plugin
Step 2: Enable the plugin
Then, 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], ];
Step 3: Configure plugin
# config/packages/_sylius.yaml imports: # ... - { resource: "@SetonoSyliusPartnerAdsPlugin/Resources/config/app/config.yaml" } # ...
Step 4: Import routing
# config/routes/setono_sylius_partner_ads.yaml setono_partner_ads_plugin: resource: "@SetonoSyliusPartnerAdsPlugin/Resources/config/routing.yaml"
Step 5: HTTP client
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
Step 6: Update your database schema
$ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate
Step 7: Setup program
Login 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.
Step 8 (optional, but recommended): Configure Async HTTP requests
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-pack
Then 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: amqp
After 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.