pycartnext
pycartnext is a simple shopping cart service built using FastAPI and Redis for caching. It provides basic cart management functionalities like adding/removing items, modifying quantities, and applying discounts.
Features
- Add, remove, and modify items in the shopping cart
- Apply discounts to the cart
- Use Redis for caching cart data
- Easy-to-use service interface for managing the cart
Installation
Prerequisites
Ensure you have Python 3.10+ and Redis installed.
Steps to install
-
Install dependencies using Poetry:
pip install pycartnext
-
Set up Redis:
- Install Redis locally or use a Redis cloud service.
- Make sure Redis is running on
redis://127.0.0.1:6379.
-
Example:
- Check example folder how to use.
Usage
CartService
The CartService class handles all cart-related operations. Here's how you can use it:
-
Create a CartService instance:
from cart_service import CartService cart_service = CartService(redis_url="redis://127.0.0.1:6379")
-
Add an item to the cart:
cart_service.add_item(title="Product A", price=100.0, quantity=2)
-
Remove an item from the cart:
cart_service.remove_item(item_id=1)
-
Increment item quantity:
cart_service.increment_item_quantity(item_id=1)
-
Decrement item quantity:
cart_service.decrement_item_quantity(item_id=1)
-
Apply a discount to the cart:
cart_service.apply_discount(discount_percentage=10)
-
Clear the entire cart:
cart_service.clear_cart()
-
View the current cart:
cart = cart_service.get_cart() print(cart)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for pycartnext 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycartnext-0.1.1.tar.gz | 4.9 kB | Without provenance | Details for pycartnext-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycartnext-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pycartnext-0.1.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / pycartnext-0.1.1.tar.gz
| Download URL | pycartnext-0.1.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9942d5ca4433d7417a02d79a356375cbff2d973ab14e542b25aa3bb2814631c7
|
|
BLAKE2b-256 checksum How to use checksums |
8771e4d32ce80a1923ce94e76a06208ca9a3d11619c46328c2cafc4c9a2a968d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-49-generic
|
Release files / pycartnext-0.1.1-py3-none-any.whl
| Download URL | pycartnext-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e84ee33bd73122be80d359176e1efcbfb5b8a74b096c10f6ff0c43183834ea0
|
|
BLAKE2b-256 checksum How to use checksums |
df90fbbb06b42bb2529ecba22ea6bb163f64639104418b10f01d203125e2ba18
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-49-generic
|
Security for pycartnext 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.