setono/sylius-klaviyo-plugin

Klaviyo integration for Sylius

Installs: 5 637

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 4

Open Issues: 8

Type:sylius-plugin

v0.3.6 2024-01-29 08:26 UTC

README

Latest Version Latest Unstable Version Software License Build Status Code Coverage

Use this plugin to integrate your store with Klaviyo.

Installation

Step 1: Download the plugin

Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:

$ composer require setono/sylius-klaviyo-plugin

Step 2: Enable the plugin

Then, enable the plugin by adding the following to the list of registered plugins/bundles in the config/bundles.php file of your project:

<?php

return [
    // ...
    
    Setono\SyliusKlaviyoPlugin\SetonoSyliusKlaviyoPlugin::class => ['all' => true],
    
    // It is important to add plugin before the grid bundle
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
        
    // ...
];

NOTE that you must instantiate the plugin before the grid bundle, else you will see an exception like You have requested a non-existent parameter "setono_sylius_klaviyo.model.member_list.class".

Step 3: Import routing

# config/routes/setono_sylius_klaviyo.yaml
setono_sylius_klaviyo:
    resource: "@SetonoSyliusKlaviyoPlugin/Resources/config/routes.yaml"

If you don't use localized URLs, use this routing file instead: @SetonoSyliusKlaviyoPlugin/Resources/config/routes_no_locale.yaml

Step 4: Configure plugin

# config/packages/setono_sylius_klaviyo.yaml
imports:
    - { resource: "@SetonoSyliusKlaviyoPlugin/Resources/config/app/config.yaml" }

setono_sylius_klaviyo:
    credentials:
        public_token: "%env(KLAVIYO_PUBLIC_TOKEN)%"
        private_token: "%env(KLAVIYO_PRIVATE_TOKEN)%"

Then remember to set these environment variables: KLAVIYO_PUBLIC_TOKEN and KLAVIYO_PRIVATE_TOKEN with the respective tokens.

Step 5: Update database schema

Use Doctrine migrations to create a migration file and update the database.

$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate

Step 6: Using asynchronous transport (optional, but recommended)

All commands in this plugin will extend the CommandInterface. Therefore you can route all commands easily by adding this to your Messenger config:

# config/packages/messenger.yaml
framework:
    messenger:
        routing:
            # Route all command messages to the async transport
            # This presumes that you have already set up an 'async' transport
            # See docs on how to setup a transport like that: https://symfony.com/doc/current/messenger.html#transports-async-queued-messages
            'Setono\SyliusKlaviyoPlugin\Message\Command\CommandInterface': async

Usage

After setup you want to associate channels with lists in Klaviyo. Go to /admin/klaviyo/member-lists/ and synchronize the lists. After that edit the lists and enable channels on the lists.