n1crack / aurora

Simple, flexible and feature-rich shopping cart library for Laravel.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aurora Shopping Cart for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub

The Aurora Shopping Cart for Laravel package provides a convenient way to manage a shopping cart in your Laravel applications. It allows you to add, update, remove items, apply conditions, and calculate the total and subtotal amounts.

Support us

..

Installation

You can install the package via composer:

composer require ozdemir/aurora

You can publish the config file with:

php artisan vendor:publish --tag="aurora-config"

This is the contents of the published config file:

<?php

return [

    'instance' => 'cart',

    'storage' => \Ozdemir\Aurora\Storage\SessionStorage::class,

];

Usage

Cart::add([
    'id'       => 'some-product',
    'name'     => 'Some Product',
    'quantity' => 1,
    'price'    => 15,
]);

$items = Cart::items(); // list of the items in the Cart

echo Cart::total();

Methods

  • add($data): Adds an item or items to the cart.
  • update($key, $data): Updates an item in the cart.
  • items(): Returns the collection of items in the cart.
  • exists($key): Checks if an item exists in the cart.
  • item($key): Retrieves an item from the cart by its key.
  • remove($key): Removes an item from the cart.
  • isEmpty(): Checks if the cart is empty.
  • total(): Calculates the total amount of the cart, including conditions.
  • subtotal(): Calculates the subtotal amount of the cart without conditions.
  • quantity(): Calculates the total quantity of items in the cart.
  • weight(): Calculates the total weight of the items in the cart.
  • clear(): Clears the cart and removes all items.
  • sync($data): Clears the cart and adds new items.
  • condition($condition): Adds a condition to the cart.
  • hasCondition($name): Checks if a condition exists in the cart.
  • removeCondition($name): Removes a condition from the cart.
  • itemConditions($type = null): Retrieves the item-level conditions in the cart.
  • conditions($type = null): Retrieves the cart-level conditions.
  • getConditionsOrder(): Gets the order of cart-level conditions.
  • getItemConditionsOrder(): Gets the order of item-level conditions.
  • setConditionsOrder(array $conditionsOrder): Sets the order of cart-level conditions.
  • setItemConditionsOrder(array $itemConditionsOrder, $updateExisting = true): Sets the order of item-level conditions.
  • serialize(): Serializes the cart instance.
  • unserialize($string): Unserializes a serialized cart instance.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Simple, flexible and feature-rich shopping cart library for Laravel.

License:MIT License


Languages

Language:PHP 100.0%