mothership-ec / cog-mothership-commerce
Cog module for commerce building blocks in Mothership
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
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/.