1. Go to this page and download the library: Download ozdemir/aurora library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ozdemir / aurora example snippets
// config/cart.php
use Ozdemir\Aurora\Cart;
use Ozdemir\Aurora\Generators\GenerateChecksum;
use Ozdemir\Aurora\Generators\GenerateSessionKey;
use Ozdemir\Aurora\Storages\SessionStorage;
return [
'instance' => 'cart',
'cart_class' => Cart::class,
'storage' => SessionStorage::class,
'cache_store' => env('CART_STORE', config('cache.default')),
'monetary' => [
'precision' => env('CART_CURRENCY_PRECISION', 2),
],
'session_key_generator' => GenerateSessionKey::class,
'checksum_generator' => GenerateChecksum::class,
'calculate_using' => [
// Custom calculators go here
],
];
// Create a product class implementing the Sellable interface
class SellableProduct implements Sellable
{
use SellableTrait;
}
// Adding an item to the cart
$product = new SellableProduct(); // Replace with your actual product model
$cartItem = new CartItem($product, quantity: 2);
Cart::add($cartItem);
// Retrieving cart information
$total = Cart::total();
$itemCount = Cart::count();
$items = Cart::items();
$itemQuantity = Cart::quantity(); // total quantity
// Adding an item with options to the cart
Cart::add(
(new CartItem($product, quantity: 1))->withOption('color', 'blue')
->withOption('material', 'metal', price: 5)
->withOption('size', 'large', weight: 4)
);
// Updating item quantity
Cart::update($cartItem->hash(), quantity: 3);
// Removing an item from the cart
Cart::remove($cartItem->hash());