mothership-ec / cog-mothership-commerce
Mothership 中用于商业模块的 Cog 模块
Requires
- php: >=5.4.0
- domisys/image_barcode2: 3.0.0
- mothership-ec/cog: ~4.10
- mothership-ec/cog-imageresize: ~2.0
- mothership-ec/cog-mothership-cp: ~3.2
- mothership-ec/cog-mothership-file-manager: ~3.1
- mothership-ec/cog-mothership-reports: ~2.1
- mothership-ec/cog-mothership-user: ~4.0
Requires (Dev)
- mockery/mockery: ~0.9
- dev-develop
- 5.20.0
- 5.19.1
- 5.19.0
- 5.18.2
- 5.18.1
- 5.18.0
- 5.17.2
- 5.17.1
- 5.17.0
- 5.16.2
- 5.16.1
- 5.16.0
- 5.15.1
- 5.15.0
- 5.14.1
- 5.14.0
- 5.13.0
- 5.12.0
- 5.11.0
- 5.10.2
- 5.10.1
- 5.10.0
- 5.9.0
- 5.8.0
- 5.7.0
- 5.6.0
- 5.5.1
- 5.5.0
- 5.4.0
- 5.3.1
- 5.3.0
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.0
- 4.9.2
- 4.9.1
- 4.9.0
- 4.8.2
- 4.8.1
- 4.8.0
- 4.7.2
- 4.7.1
- 4.7.0
- 4.6.0
- 4.5.2
- 4.5.1
- 4.5.0
- 4.4.2
- 4.4.1
- 4.4.0
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.1
- 4.0.0
- 3.6.1
- 3.6.0
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.0
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-master
- dev-feature/dont-load-deleted-product-units
- dev-feature/unit-form-changes
- dev-feature/image-option-casing
- dev-feature/unit-loader-fixes
- dev-feature/admin-rebuild
- dev-feature/loader-accessors
- dev-feature/sales-product-names
- dev-feature/product-filters-user-report
- dev-feature/units-dont-include-deleted
- dev-feature/product-option-loader-changes
- dev-feature/optimise-unit-loader
- dev-feature/optimise-stock-report
- dev-feature/unit-tests
- dev-feature/pageloader-pagination-mpty-by-id
- dev-feature/filter-fix
- dev-feature/csv-convert-date-to-timestamp
- dev-feature/discounts-on-reports
- dev-feature/order-listing-pagination-fix
- dev-feature/delete-addresses
- dev-beta-features
- dev-feature/order-overview
- dev-feature/product-selector
- dev-compatibility/stoneham
- dev-feature/tax-strategy-loader-fix
- dev-feature/add-get-payments-to-payable
- dev-feature/ux/order-improvements
- dev-compatibility/epos_v2
- dev-compatibility/union-music-store
- dev-feature/image-looping-bug
- dev-feature/ux/product-process
- dev-feature/escape-fixes
- dev-feature/issue-292-required-sku
- dev-feature/loader-optimisation
- dev-feature/3.6.0
- dev-compatibility/ums-lazy-loading
- dev-feature/patch-362
- dev-feature/oos-email-signup
- dev-compatibility/union-music-store-dashboards
- dev-feature/image-loading-bugfix
- dev-feature/item-populate
- dev-compatibility-types-loading-payments
- dev-feature/serialized-loader-bug
- dev-feature/refund-create-event
- dev-compatibility-types-and-loading
- dev-compatibility/epos
- dev-mob-refactor/addresses
- dev-feature/patch-122
- dev-feature/154-add-mexican-states
- dev-feature/250-format-documents
- dev-feature/250-reprint-document-formatting
- dev-feature/product-types
- dev-feature/separate-taxable-events
- dev-cancel-url
- dev-cog-issue-201-country-list
- dev-feature/153-add-notes
- dev-forex
- dev-order-taxability
This package is not auto-updated.
Last update: 2021-03-22 11:08:02 UTC
README
Message\Mothership\Commerce
Cogule 为 Mothership 提供基本的商业功能。这构成了 ECommerce
和 EPOS
建筑块的组成部分。
安装
使用 Composer 安装此包。包名为 message/cog-mothership-commerce
。
您需要在 composer.json
中的 repositories
键中添加 Message 的私有包服务器。
{
"repositories": [
{
"type": "composer",
"url" : "http://packages.message.co.uk"
}
],
"require": {
"message/cog-mothership-commerce": "~4.1"
}
}
##产品 A 产品对象代表一个特定的产品。它们提供诸如类别和品牌以及价格等属性。单位允许对产品进行变体,例如“尺寸”和“颜色”。因此,在向用户显示价格时通常更希望使用单位而不是产品。
如果单位上没有提供价格,则默认为产品价格。
##产品\类型 每个产品都有一个与其关联的类型。类型的主要用途是允许不同产品需要不同的信息。例如,MusicProductType
需要提供艺术家。类型还允许将“显示名称”设置为不同的格式。
用于在管理面板中使用的类型在 IoC 中设置为服务 product.types
。只有在服务容器中注册的类型才能在创建产品时使用。
##产品\价格 产品定价对象是一组价格(浮点数),映射到货币和区域。产品和单位对象都有一个定价对象,它们在调用 getPrice()
、getNetPrice()
等时使用。该对象负责根据货币和区域获取正确的价格以显示。
##产品\税 通过 TaxResolverInterface
实例将产品税加载到产品上。使用这些税率和一个 TaxStrategyInterface
实例计算净价和含税价。
###TaxResolver TaxResolverInterface
是一个接口,用于一个将获取一个令牌和一个 Address
并返回包含该令牌/地址组合所有适用税率 TaxCollection
的类的接口。默认情况下,使用 TaxResolver
。它查看 tax.yml
文件以解析税。
###TaxStrategy 虽然可以实现接口以提供更多税策略,但实际使用中只有两种税策略将被使用。这些是含税和不含税。这些在商业模块中提供。
产品\库存
通用
Product\Stock
负责处理库存变化。每次库存变化都以库存调整(Product\Stock\Movement\Adjustment\Adjustment
)的形式记录。在同一操作(创建新订单/在单个请求中调整库存水平)中创建的库存调整被库存移动(Product\Stock\Movement\Movement
)所包围,以提供原因、作者等信息。
库存管理器
库存管理器 Product\Stock\StockManager
负责创建和保存新的库存变动(和调整)。请阅读 Product\Stock
的详细说明文档以获取更多信息!
变动迭代器
此外,还有一个库存变动的迭代器,允许您遍历库存历史记录并获取在任何变动之前或之后的库存水平。请阅读 Product\Stock
的详细说明文档以获取更多信息!
产品页面映射器
商业包包含两个产品页面映射器的实现:SimpleMapper
和 OptionCriteriaMapper
。默认情况下,SimpleMapper
被别名到 product.page_mapper
。
配置
要使映射器能够正确地将产品与页面关联起来,您必须设置产品页面的 product_content.field_name
和 product_content.group_name
的有效值。此外,您还应设置有效的页面类型。您可以使用以下方式更改这些设置:
$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; });
这些默认值为
- 字段名称:
'product'
- 组名称:
null
- 页面类型:
'product'
简单映射器
简单映射器仅将基本产品映射到页面。
用法
// 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);
选项条件映射器
选项条件映射器还可以应用特定产品选项的过滤器,例如 ['colour' => 'red']
。您可以传递任意数量的选项:['colour' => 'red', 'size' => 'medium']
。
要启用选项条件映射器,您必须在您的服务中将别名映射到页面映射器
$services['product.page_mapper'] = $services->raw('product.page_mapper.option_criteria');
用法
除了前面的方法之外,您还可以调用
// 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);
自定义映射器
在编写自定义映射器时,您应该扩展 AbstractMapper
以确保兼容性。
过滤器
您可以传递过滤器回调函数,这些回调函数在从数据库检索结果后应用。从回调函数返回 false
将从结果中删除对象。
用法
$services->extend('product.page_mapper', function($mapper, $c) { $mapper->addFilter(function($obj) { if ($obj instanceof Page) { return (false !== stristr($obj->title, "foo")); } }); return $mapper; });
许可
Mothership E-Commerce 版权 (C) 2015 Jamie Freeman
本程序是自由软件:您可以重新分发它并/或修改它,前提是您必须根据自由软件基金会发布的 GNU 通用公共许可证的条款,许可证版本 3 或(根据您的选择)任何后续版本。
本程序分发的目的是希望它有用,但没有任何保证;甚至没有关于其可销售性或适用于特定目的的暗示性保证。有关详细信息,请参阅 GNU 通用公共许可证。
您应已收到一份 GNU 通用公共许可证副本。如果没有,请参阅 https://gnu.ac.cn/licenses/。