承接 tungsten/growdough 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tungsten/growdough

Composer 安装命令:

composer require tungsten/growdough

包简介

This plugin allows collecting donation designations in a Donations List that works similar to a shopping cart.

README 文档

README

This plugin allows collecting donation designations in a Donations List that works similar to a shopping cart.

Screenshot

Requirements

This plugin requires Craft CMS 4.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require tungsten/growdough
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for GrowDough.

Settings

  • Donations URL: Stores the full URL to the donations form for the account
  • Test Mode Enabled: Allows to test the GrowDough integration with the Craft website. When enabled, the Test Mode is enabled during the checkout on GrowDough.

When the test mode is enabled, the following hidden input is added to the form:

<input id="growdough_test_mode" name="test_mode" value="true" type="hidden">

Variables

getDonationItems

Retrieves the donation items stored in the session as a collection (array). Use the collection in a for loop to build the items list.

{# Get the Donation Items stored in the session. Returns false if there are no Donation Items #}
{% set donationItems = craft.growDough.getDonationItems %}

donationItemInList

Check if the donation item with the provided id is already in the list of donation items.

{% if craft.growDough.donationItemInList(fund.id) %}
  {# If the item is already in the donation list, show disabled button #}
  <a href="#" class="btn disabled" disabled="disabled">Selected</a>
{% else %}
  {# Ir the item is NOT in the donation list, show the button to add it to the list. #}
  <input class="btn give-now" type="submit" title="Add to Donation List" value="Give Now">
{% endif %}

addDonationItemFormTag

Opening form tag to add a donation item to the donation items list.

Params

  • itemId Unique id for the donation item
  • itemTitle Donation item title that is used for display
  • itemAttributes Donation item attributes array that will be stored as JSON

Example

{{ craft.growDough.addDonationItemFormTag(
  fund.id,
  fund.title,
  {
    'Donation Type': 'Scholarship Fund',
    'Donating To': 'The Erie Art Museum',
    'Designation': fund.title
  }
) }}

formTag

Opening form tag to submit donation to GrowDough. Includes the GrowDough post URL and all hidden fields required for submission.

Options

  • templateVariables Include the template variables that should be used in the GrowDough donation workflow (donation form, email receipt, thank you page, etc.) If not included, an empty JSON array will be submitted.
  • donationItems Include an array of donation items to override the items in the donation list. If not included, an array of donation items will be automatically generated from the donation list.
  • paymentMethod Include a predefined payment method (credit_card or giving_card) if the form is intended to use a pre-determined GrowDough donation form.
  • donationAmount Include a predefined donation amount if the form is intended to use a pre-determined amount on the GrowDough donation form.

Most Common Use

The form tag will be most commonly used with templateVariables and paymentType.

{{ craft.growDough.formTag({
  'templateVariables': {
    'Variable Key': 'Variable Value',
    'Variable Key': 'Variable Value',
    ...
  },
  'paymentMethod': 'credit_card|giving_card',
  'donationAmount': 100
}) }}

Full Variable Syntax

{{ craft.growDough.formTag({
  'templateVariables': {
    'Variable Key': 'Variable Value',
    'Variable Key': 'Variable Value',
    ...
  },
  'donationItems': [
    {
      "title": "Item title",
      "attributes": {
        "Attribute Key": "Attribute Value",
        "Attribute Key": "Attribute Value",
        ...
      }
    },
    {
      "title": "Item title",
      "attributes": {
        "Attribute Key": "Attribute Value",
        "Attribute Key": "Attribute Value",
        ...
      }
    }
  ],
  'paymentMethod': 'credit_card|giving_card',
  'donationAmount': 100
}) }}

getDonationItemsJson

Format the donation items list as an encoded JSON string.

{{ craft.growDough.getDonationItemsJson }}

donationsUrl

Retrieves the GrowDough donations URL from the plugin settings. The URL is used to post the donation to the GrowDough system for the particular account.

<form action="{{ craft.growDough.donationsUrl }}" method="post">

givingCardPurchaseUrl

Retrieves the GrowDough Giving Card purchase URL from the plugin settings. The URL is used to post the desired Giving Card amount to the GrowDough system for the particular account.

<form action="{{ craft.growDough.givingCardPurchaseUrl }}" method="post">

Actions

Add Donation Item to Dontation Items

Add a specific donation item to the Donations List. If an item with the provided itemId already exists in the list, it will NOT be added.

Example using addDonationItemFormTag variable

{{ craft.growDough.addDonationItemFormTag(
  fund.id,
  fund.title,
  {
    'Attribute Key': 'Attribute Value',
    'Attribute Key': 'Attribute Value',
    ...
  }
) }}
  <h3>{{ fund.title }}</h3>
  <input class="btn give-now" type="submit" title="Add to Donation List" value="Give Now">
</form>

Example using HTML form directly

{% set itemId = fund.id %}
{% set itemTitle = fund.title %}
{% set itemAttributes = {
  'Attribute Key': 'Attribute Value',
  'Attribute Key': 'Attribute Value',
  ...
} %}
<form method="post" action="" accept-charset="UTF-8">
  <input type="hidden" name="action" value="growDough/addDonationItem">
  <input type="hidden" name="itemId" value="{{ itemId }}">
  <input type="hidden" name="itemTitle" value="{{ itemTitle }}">
  <input type="hidden" name="itemAttributes" value="{{ itemAttributes|json_encode()|e }}">
  <h3>{{ fund.title }}</h3>
  <input class="btn give-now" type="submit" title="Add to Donation List" value="Give Now">
</form>

Redirecting to another page upon submission

By default, upon form submission the plugin will automatically reload the current page.

To override this default behavior, include redirectInput function after the PerForm addDonationItemFormTag and specify your redirect destination.

{{ craft.growDough.addDonationItemFormTag(
  fund.id,
  fund.title,
  {
    'Attribute Key': 'Attribute Value',
    'Attribute Key': 'Attribute Value',
    ...
  }
) }}
{{ redirectInput('some/url/here') }}

OR

<form method="post" action="" accept-charset="UTF-8">
  <input type="hidden" name="action" value="actions/growdough/default/add-donation-item">
  <input type="hidden" name="itemId" value="{{ itemId }}">
  <input type="hidden" name="itemTitle" value="{{ itemTitle }}">
  <input type="hidden" name="itemAttributes" value="{{ itemAttributes|json_encode()|e }}">
  {{ redirectInput('some/url/here') }}

removeDonationItem

Remove a specific donation item from the Donations List. If an item with the provided itemId does not exist in the list, the action will be ignored.

<a href="{{ url('grow-dough/remove-donation-item', { itemId: itemId }) }}">Remove</i>

Optional: Add a redirectUrl parameter if you'd like to redirect to a specific page after the item is added. If the parameter is omitted, the browser will redirect to the origin page (using http_referrer).

<a href="{{ url('grow-dough/remove-donation-item', { itemId: itemId, redirectUrl: 'some/url/here' }) }}">Remove</i>

removeAllDonationItems

Remove all donation items from growDoughItems session variable. This is useful when checking out a multi-designation donation and the session needs to be remove so that it does not stick around after the donation is complete.

This action needs to be called via AJAX while the GrowDough form is being submitted.

$.get('/growdough/remove-all-donation-items', { deleteAll: true }, function(response) {
  console.log('Deleted ' + response.item_count + ' donation items.');
});

Brought to you by Tungsten Creative Group

tungsten/growdough 适用场景与选型建议

tungsten/growdough 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 129 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 tungsten/growdough 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-28