Skip to main content

Install with pip

$ pip install garpix_cart

Add the garpix_cart to your INSTALLED_APPS:

# settings.py

INSTALLED_APPS = [
    # ...
    'garpix_cart',
]

Make migrations and migrate database:

$ ./manage.py makemigrations
$ ./manage.py migrate

Add to urls.py:

urlpatterns = [
    # ...
    path('', include('garpix_cart.urls'))
]

Customize

By default, you will see in settings.py:

GARPIX_CART_SESSION_KEY = 'cart' # cart session key

GARPIX_CART_MIXIN = 'garpix_cart.mixins.CartMixin' # base Cart mixin to model
GARPIX_CART_SESSION_CLASS = 'garpix_cart.base.BaseCartSession' # base cart session core
GARPIX_CART_SESSION_HANDLER_CLASS = 'garpix_cart.base.BaseCartHandler' # base cart handler, which inherit all handlers

Easy way to customize

For example, we want to have our own BaseCartHandler:

  1. override as needed;

# base.py

from garpix_cart.base import BaseCartHandler


class CustomHandler(BaseCartHandler):
    def validate(self, products) -> List[Dict[str, Any]]:
        return products

Where products is received data from request

  1. Change handler in settings.py;

# settings.py

GARPIX_CART_SESSION_HANDLER_CLASS = 'app.base.CustomHandler'
  1. This work fine!

The hard way to customize

  1. Create your class inherited from abstract;

# base.py

from garpix_cart.abstracts import AbstractCartHandler


class CustomHandler(AbstractCartHandler):
    def validate(self, products) -> List[Dict[str, Any]]:
        # method validates the data from the request

        ...

    def is_valid(self, products) -> bool:
        # check data is valid

        ...

    def make(self, products) -> bool:
        # make if data is valid
        # always returns modify_session() from CartSession class

        ...

    def error_log(self, products) -> Optional[str]:
        # get errors if they raises

        ...
  1. Change handler in settings.py;

# settings.py

GARPIX_CART_SESSION_HANDLER_CLASS = 'app.base.CustomHandler'
  1. This work fine!

Developed by Garpix / https://garpix.com

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garpix_cart-2.0.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garpix_cart-2.0.0-py3-none-any.whl (30.5 kB view details)

Uploaded Python 3

File details

Details for the file garpix_cart-2.0.0.tar.gz.

File metadata

  • Download URL: garpix_cart-2.0.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for garpix_cart-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4d0ea470f12f2c649b211089079ca5249161afe0c94a3eb5ac57fc2da71f7f28
MD5 ab0d3e64cac49a1a26af65fc08d70986
BLAKE2b-256 0bc0648a79eb80ccf7f7217278763180fcc41e8810a436c1a1acaafc25a539a8

See more details on using hashes here.

File details

Details for the file garpix_cart-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: garpix_cart-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 30.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for garpix_cart-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66b348b7291211bcc9a1f86dacbb8f22ab85763f99d0f645830c40ceff2cc8e0
MD5 44db65c772ebb747d25b8e161ff3b823
BLAKE2b-256 1c0daf04dd8890149ce872fa8a00f12abb8ce1733b25ac131fe08125480de6eb

See more details on using hashes here.

Release history Release notifications | RSS feed

3.0.0

2 files

2.2.0

2 files

2.1.0

2 files

This release

2.0.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page