定制 clarknelson/craft-mailchimp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clarknelson/craft-mailchimp

Composer 安装命令:

composer require clarknelson/craft-mailchimp

包简介

A plugin to assist with managing the connection to your MailChimp account.

README 文档

README

This is a Craft CMS plugin to connect with the Mailchimp email marketing API.

Install

You will want to install this plugin from the command line or the plugin page.

Config

The settings can be provided through the settings page /admin/settings/plugins/craft-mailchimp.

Or they can be provided in a php file /config/craft-mailchimp.php:

<?php
return [
    'apiKey' => 'b3e485720d0fb51f01884d4289e62d15-us10',
    'dataCenter' => 'us10',
    'defaultListId' => '2345b79e5f',
];

These can also be set in the .env which will take highest priority in the load order.

MAILCHIMP_API_KEY=b3e485720d0fb51f01884d4289e62d15-us10
MAILCHIMP_API_PREFEX=us10
MAILCHIMP_LIST_ID=2345b79e5f

The API Key can be found in the Mailchimp Admin panel under your user settings. ds.admin.mailchimp.com/account/api where ds is your accounts data center (ie us10).

This setting is required for the plugin to work correctly.

The data center would be the prefix or suffix for the API key, for example us10. This is optional and will try to be parsed from the API key that is provided.

To use a specific audience on your account, use that list's Audience ID found on the settings page at ds.admin.mailchimp.com/lists/settings/default?id=web-id. By default the first audience on your account will be used, so this may not be required if you are using a single list on your account.

Usage

Mailchimp PHP API

If the plugin was installed and configured correctly, the entire Mailchimp PHP API should be exposed for use on the front-end.

For example, if the PHP code in the API docs is as follows:

$response = $client->lists->getAllLists();

To retrieve all of the audience / lists on the account. You would write the following in twig:

{% set response = craft.mailchimp.client.lists.getAllLists() %}
{% for list in response.lists %}
    <a href="{{ list.subscribe_url_short }}" target="_blank">{{ list.name }}</a>
{% endfor %}

Which will list each audience on your account, linked to it's sign up form.

While all of the methods should be available please be very careful running queries. Keep in mind that twig should display data, not modify data, so avoid the POST / PUT / DELETE methods and concentrate on the functions that use GET methods.

The Lists API is a good starting point for figuring out what you want to do.

Connected Sites (Pro)

This plugin supports connected sites for adding popups and similar elements to your Craft website through the Mailchimp interface.

It is easy to get started, simply add this script to the <head> of your document.

{{ craft.mailchimp.connectSite() | raw }}

This will output the correct <script> tag so your website can connect with Mailchimp.

Form Input Tags (Pro)

I have created a system to help sign up users to a Mailchimp list from any form using hidden input fields.

Required Tags

{{ hiddenInput('MAILCHIMP_SUBSCRIBE_CHECKBOX', 'mailchimpSubscribe') }}
{{ hiddenInput('MAILCHIMP_SUBSCRIBE_EMAIL', 'emailAddress') }}

The MAILCHIMP_SUBSCRIBE_CHECKBOX field determines whether to subscribe or unsubscribe a user from the list. This can be true or false, or a string in which case it will be asummed to be the name attribute of a checkbox field which will determine the truthiness.

The MAILCHIMP_SUBSCRIBE_EMAIL field is the name attribute for the email address input field which will be subscribed to the list. For example:

<input type="checkbox" name="mailchimpSubscribe" checked>
<input type="email" name="emailAddress" placeholder="email@domain.com">

This way you should be able to add the Mailchimp functionality to any existing form.

Optional Tags

{{ hiddenInput('MAILCHIMP_SUBSCRIBE_LIST_ID', '2345b79e4f') }}

{{ hiddenInput('MAILCHIMP_SUBSCRIBE_FNAME', 'firstName') }}
{{ hiddenInput('MAILCHIMP_SUBSCRIBE_LNAME', 'lastName') }}
{{ hiddenInput('MAILCHIMP_SUBSCRIBE_PHONE', 'phoneNumber') }}

The MAILCHIMP_SUBSCRIBE_LIST_ID input can be provided to add to a specific mailchimp list. Otherwise the first list in the account will be used.

The MAILCHIMP_SUBSCRIBE_FNAME, MAILCHIMP_SUBSCRIBE_LNAME, and MAILCHIMP_SUBSCRIBE_PHONE all refer to merge fields in the Mailchimp list. These are additional pieces of information associated with the user. Any MAILCHIMP_SUBSCRIBE_ input provided that does not end with CHECKBOX, EMAIL, or LIST_ID is assumed to be a merge field.

clarknelson/craft-mailchimp 适用场景与选型建议

clarknelson/craft-mailchimp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「mailchimp」 「newsletter」 「newsletters」 「Craft」 「craft cms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 clarknelson/craft-mailchimp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 clarknelson/craft-mailchimp 我们能提供哪些服务?
定制开发 / 二次开发

基于 clarknelson/craft-mailchimp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2022-09-20