Cart
Use the ffCart plugin to implement functionality such as shopping carts, whishlist and other related functionality
user interface
in your template, write like so:
<button data-ff-cart-api="addToCart">add to cart</button>`
ffCartListener provides the following default methods:
addItem([
'trace' => 'trace,to,node',
'qty' => null // optional
])
removeItem([
'trace' => 'trace,to,node'
])
incrementItemQuantity([
'trace' => 'trace,to,node',
'qty' => null // optional
])
decrementItemQuantity([
'trace' => 'trace,to,node',
'qty' => null // optional
])
getTotalItemCount()
working with the ffCart object
Create a prefixed per-project class
file classes/nsCart.php
class nsCart extends ffCart{
// project-specific overwrites and functionality
}
Wherever you need the cart from within any equally prefixed class, you can instantiate it like this:
$cart = ffCart::getInstance(); // will return an instance of nsCart
$cart = nsCart::getInstance(); // will also return an instance of nsCart
ffCart provides the following default methods:
28 März 2024