neosrulez / neos-cart
该软件包最新版本(0.0.1)没有提供许可证信息。
Neos Flow应用程序的购物车软件包。
0.0.1
2023-05-31 07:39 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- gedmo/doctrine-extensions: ^3.10 || *
- neos/flow: ^6.0 || ^7.0 || ^8.0
This package is not auto-updated.
Last update: 2024-09-19 13:15:31 UTC
README
Neos Flow应用程序的购物车软件包。
安装
只需运行
composer require neosrulez/neos-cart
配置
NeosRulez: Neos: Cart: isNetCart: true slots: summary: subTotal: class: '\Acme\Package\Domain\Service\Cart\Summary\SubTotal' # executes the action "execute" and pass arguments to overrule the default action taxes: class: '\Acme\Package\Domain\Service\Cart\Summary\Taxes' # executes the action "execute" and pass arguments to overrule the default action total: class: '\Acme\Package\Domain\Service\Cart\Summary\Total' # executes the action "execute" and pass arguments to overrule the default action
使用
创建一个表单。无论是Neos Fusion表单还是React组件中的简单HTML表单。
<form> <!-- Required properties for item--> <input type="text" name="item[quantity]" value="1" /> <input type="hidden" name="item[sku]" value="StockKeepingUnit" /> <input type="hidden" name="item[price]" value="25.50" /> <input type="hidden" name="item[tax]" value="20.00" /> <!-- Your custom item properties--> <input type="text" name="item[properties][foo]" value="Foo" /> <input type="text" name="item[properties][bar]" value="Bar" /> <input type="text" name="item[properties][bars]" value="Bars" /> <button type="submit">Add to cart</button> </form>
use NeosRulez\Neos\Cart\Domain\Model\Cart; use NeosRulez\Neos\Cart\Domain\Model\Cart; use NeosRulez\Neos\Cart\Domain\Dto\Shipping; // Inject cart session model /** * @Flow\Inject * @var Cart */ protected $cart; // Item $this->cart->add($item); $this->cart->update($item); $this->cart->delete($item); // Cart $items = $this->cart->getItems(); $shipping = $this->cart->getShipping(); $summary = $this->cart->getSummary(); $this->cart->flush(); // Summary $newShipping = new Shipping(); $newShipping->setPrice(14.90); $newShipping->setTax(20); $newShipping->setProperty('name' => 'Worldwide shipping'); $this->cart->setShipping($shipping);