承接 craftcms/commerce-taxjar 相关项目开发

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

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

craftcms/commerce-taxjar

Composer 安装命令:

composer require craftcms/commerce-taxjar

包简介

TaxJar Integration for Craft Commerce

README 文档

README

TaxJar icon

TaxJar for Craft Commerce

This plugin provides a tax integration between Craft Commerce and TaxJar.

It replaces Craft Commerce’s built-in tax engine, offloading the work of managing tax rates, tax zones, and tax categories to TaxJar.

Requirements

This plugin requires either Craft Commerce 5.0 or later.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “TaxJar”. Then click on the “Install” button in its modal window.

With Composer

Open your terminal and run the following commands:

# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require craftcms/commerce-taxjar

# tell Craft to install the plugin
php craft install/plugin commerce-taxjar

Configuration & Setup

Step 1: Configure the plugin

The plugin has two TaxJar API connection settings. To set them, follow these steps:

  1. Define new TAXJAR_API_KEY and TAXJAR_SANDBOX environment variables in your .env file (or wherever you manage your environment variables).

    # Set to your TaxJar API key
    TAXJAR_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    # Set to 0 or 1 depending on whether the sandbox API endpoint should be used
    TAXJAR_SANDBOX="1"
    
  2. Create a config/commerce-taxjar.php file with apiKey and useSandbox settings, which pull in the environment variables.

    <?php
    
    return [
        'apiKey' => getenv('TAXJAR_API_KEY'),
        'useSandbox' => (bool)getenv('TAXJAR_SANDBOX'),
    ];

Step 2: Sync your tax categories

To sync your tax categories with TaxJar, go to Commerce → Tax → Tax Categories in your control panel, and click on the “Sync” button.

Once the sync is complete, you will be free to edit the synced tax categories, and assign them to products as you normally would.

Warning: Don’t change the tax category handles, as that will cause duplicate tax categories to appear the next time you sync.

Step 4: Check your store location

Go to Commerce → Store Settings → Store Location, and ensure that everything is set correctly there. The plugin will use this info to populate the from address when getting tax info from TaxJar.

Usage

Once the plugin is set up properly, tax adjustments will be added to new orders automatically, per the line items’ tax categories.

When the TaxJar API is queried for tax info, the full API response is JSON-encoded and stored in the tax adjustment’s sourceSnapshot value.

Events

craft\commerce\taxjar\adjusters\TaxJar::EVENT_MODIFY_TAX_FOR_ORDER_REQUEST

Raised just before the TaxJar API is queried for an order's tax. Allows you to modify the request parameters sent to TaxJar's taxForOrder endpoint.

The event is an instance of craft\commerce\taxjar\events\ModifyRequestEvent, which has the following properties:

Property Type Description
requestParams array The parameters that will be sent to the TaxJar API. Modify this to change the request.
order craft\commerce\elements\Order The order being calculated.
address craft\elements\Address The shipping address of the order.

Example — adding a customer exemption:

use craft\commerce\taxjar\adjusters\TaxJar as TaxJarAdjuster;
use craft\commerce\taxjar\events\ModifyRequestEvent;

Event::on(
    TaxJarAdjuster::class,
    TaxJarAdjuster::EVENT_MODIFY_TAX_FOR_ORDER_REQUEST,
    function(ModifyRequestEvent $event) {
        $customer = $event->order->getCustomer();

        if ($customer && $customer->group === 'wholesale') {
            $event->requestParams['exemption_type'] = 'wholesale';
            $event->requestParams['customer_id'] = (string)$customer->id;
        }
    }
);

Feature Roadmap

  • Pull live rates for a cart from TaxJar.
  • Replace the built in tax engine in Craft Commerce
  • Sync tax categories with TaxJar
  • Sync completed orders with TaxJar for reporting purposes
  • Sync customers TaxJar for reporting and tax exemption purposes

craftcms/commerce-taxjar 适用场景与选型建议

craftcms/commerce-taxjar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.2k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 04 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 craftcms/commerce-taxjar 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-02