neosrulez/neos-cart

There is no license information available for the latest version (0.0.1) of this package.

A shopping cart package for Neos Flow applications.

0.0.1 2023-05-31 07:39 UTC

This package is not auto-updated.

Last update: 2024-11-14 14:12:14 UTC


README

A shopping cart package for Neos Flow applications.

Installation

Just run:

composer require neosrulez/neos-cart

Configuration

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

Usage

Create a form. Whether it's a Neos Fusion form or a simple HTML form in a React component.

<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);

Routes

Author