kollarovic / shopping-cart
Shopping Cart for Nette
2.0.0
2019-05-27 13:56 UTC
Requires
- php: >=5.4.0
- kollarovic/thumbnail: ~2.0
- latte/latte: ~2.2
- nette/application: ~2.2
- nette/bootstrap: ~2.2
- nette/forms: ~2.2
- nette/utils: ~2.2
Requires (Dev)
- nette/tester: ~1.3
This package is auto-updated.
Last update: 2024-11-18 06:54:48 UTC
README
Live Demo
Installation
composer.json
{ "require":{ "kollarovic/shopping-cart": "dev-master" } }
config.neon
extensions: cart: Kollarovic\ShoppingCart\DI\Extension thumbnail: Kollarovic\Thumbnail\DI\Extension
presenter
namespace App\FrontendModule\Presenters; use Kollarovic\ShoppingCart\Cart; use Kollarovic\ShoppingCart\ICartControlFactory; use Nette\Database\Context; class CartPresenter extends BasePresenter { /** @var Cart @inject */ public $cart; /** @var ICartControlFactory @inject */ public $cartControlFactory; /** @var Context @inject */ public $database; public function actionAdd($id) { $product = $this->database->table('product')->get($id); if (!$product) $this->error(); $this->cart->addItem($product->id, $product->price) ->setName($product->name) ->setImage($product->image) ->setUnit($product->unit) ->setVatRate($product->vat) ->setLink('Product:default') ->setLinkArgs($product->id); $this->redirect('default'); } protected function createComponentCartControl() { $cartControl = $this->cartControlFactory->create(); $cartControl->onClickContinue[] = function() { $this->redirect('Homepage:default'); }; $cartControl->onClickNext[] = function() { $this->redirect('Order:default'); }; return $cartControl; } }
default.latte
{control cartControl}
Optional settings
config.neon
cart: columns: image: yes name: yes price: no quantity: yes totalWithoutVat: yes total: yes delete: yes price: currency: € decimals: 2 decimalPoint: ',' thousandsSep: ' ' priceFormat: '{price} {currency}' buttons: next: Checkout continue: Continue shopping update: Update image: width: 80 height: 80