定制 mothership-ec/cog-mothership-commerce 二次开发

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

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

mothership-ec/cog-mothership-commerce

最新稳定版本:5.20.0

Composer 安装命令:

composer require mothership-ec/cog-mothership-commerce

包简介

Cog module for commerce building blocks in Mothership

README 文档

README

The Message\Mothership\Commerce Cogule provides base commerce functionality for Mothership. This forms part of the building blocks for both ECommerce and EPOS.

Installation

Install this package using Composer. The package name is message/cog-mothership-commerce.

You will need to add Message's private package server to the repositories key in composer.json:

{
	"repositories": [
		{
			"type": "composer",
			"url" : "http://packages.message.co.uk"
		}
	],
	"require": {
		"message/cog-mothership-commerce": "~4.1"
	}
}

##Product A Product object represents a certain product. They provide attributes such as the category and brand as well a prices. Units allow Variants on Products such as "size" and "colour". For this reason, it is usually desirable to use Units over Products when displaying prices to users.

If no prices are provided on a Unit, it will default to the Product prices.

##Product\Types Each product has a Type associated to it. The main use of a Type is to allow different information to be required by different products. For example a MusicProductType requires an Artist to be provided. Types also allow the "display name" to be set into to a different format.

Types provided for use within the admin panel are set in the IoC as the service product.types. Only types registered in the service container may be used when creating products.

##Product\Price The product Pricing object is a group of prices (float) mapped against Currency and Locale. Product and Unit objects have a Pricing object which they use when calling getPrice(), getNetPrice() etc. This object does the legwork of getting the correct price to display based on currency and locale.

##Product\Tax Product taxes are loaded onto the product using an instance of TaxResolverInterface. Net and Gross prices are calculated using these tax rates and an instance of TaxStrategyInterface.

###TaxResolver The TaxResolverInterface is an interface for a class that will take a token and an Address and return a TaxCollection containing all the applicable tax rates for that token/address combination. By default, the TaxResolver is used. This looks within the tax.yml file to resolve taxes.

###TaxStrategy Whilst it is possible to implement the interface to provide further tax strategies, realistically there are only two which will be used. These are Tax Inclusive and Tax Exclusive. These are provided within Commerce.

Product\Stock

General

Product\Stock is responsible for handling stock changes. Every stock change is documented as a stock adjustment(Product\Stock\Movement\Adjustment\Adjustment). Stock adjustments created within the same action(creating a new order/ adjusting stock levels in one request) are surrounded by a stock movement(Product\Stock\Movement\Movement), to give them a reason, authorship, etc.

Stock Manager

The stock manager Product\Stock\StockManager is responsible for creating and saving new stock movements (and adjustments). Please read the detailed readme of Product\Stock for more information!

Movement Iterator

Also there is an Iterator for stock movements, which allows you to iterate over the stock history and get the stock level at any time before or after a movement. Please read the detailed readme of Product\Stock for more information!

Product Page Mapper

The commerce package ships with two implementations of the product page mapper: SimpleMapper and OptionCriteriaMapper. By default the SimpleMapper is aliased to product.page_mapper.

Configuration

To enable the mapper to correctly relate products to pages you must set the valid values for product_content.field_name and product_content.group_name for product pages. Additionally you should set the valid page types. You can change these using:

$services->extend('product.page_mapper', function($mapper, $c) {
	$mapper->setValidFieldNames('product');

	// Passing an array to either method will match against all values
	$mapper->setValidGroupNames(['product', 'showcase']);

	// Passing false to the group name will exclude pages within any group
	$mapper->setValidGroupNames(false);

	// Passing null or an empty array to the group name will match pages with
	// any or no group
	$mapper->setValidGroupNames([]);

	$mapper->setValidPageTypes(['product', 'strap']);

	return $mapper;
});

These default to:

  • Field Names: 'product'
  • Group Names: null
  • Page Types: 'product'

Simple Mapper

The simple mapper just matches a basic product to a page.

Usage

// Find a page from a product
$page = $services['product.page_mapper']->getPageForProduct($product);

// Find a product from a page
$product = $services['product.page_mapper']->getProductForPage($page);

Option Criteria Mapper

The option criteria mapper can additionally apply a filter for a specific product option, for example ['colour' => 'red']. You can pass any number of options: ['colour' => 'red', 'size' => 'medium'].

To enable the option criteria mapper you must alias it to the page mapper in your services:

$services['product.page_mapper'] = $services->raw('product.page_mapper.option_criteria');

Usage

In addition to the previous methods, you can also call:

// Find all pages from a product
$pages = $services['product.page_mapper']->getPagesForProduct($product, ['colour' => 'red']);

// Find a page from a unit
$page = $services['product.page_mapper']->getPageForProductUnit($unit);

// Find units from a page
$units = $services['product.page_mapper']->getProductUnitsForPage($page);

Custom Mappers

When writing a custom mapper you should extend AbstractMapper to ensure compatibility.

Filters

You can optionally pass in filter callbacks that are applied after the results are pulled from the database. Returning false from the callback will remove the object from the results.

Usage

$services->extend('product.page_mapper', function($mapper, $c) {
	$mapper->addFilter(function($obj) {
		if ($obj instanceof Page) {
			return (false !== stristr($obj->title, "foo"));
		}
	});

	return $mapper;
});

License

Mothership E-Commerce Copyright (C) 2015 Jamie Freeman

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

mothership-ec/cog-mothership-commerce 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 25
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-02-24