Skip to main content

Package from the ecs suite, that provide a cart object for ecommerce projects

Project description

ECS CART

This is a package from the ecs suite, that provide a cart object for ecommerce projects.

In standart use it provide classical functionnalities:
  • Add/delete product from cart

  • Price manipulation and amount (with vat)

  • Weight amount

  • Reductions (in % or value)

But this package also provide rules system that add the posibility to improve his functionnalities (like connection with database, logistic function, …)

Read docs/source/module/README.txt or inline http://docs.emencia.net/ecs.cart

Ecs cart Changelog

O.3 (December 15, 2008)

  • fix docstest

  • fix bug in rules config

O.2 (December 10, 2008)

  • use now sphinx for doc and nose for testing

  • re-develop the rules config with classical python conf files and paste for import modules

0.1 (October 22, 2008)

  • project creation

ecscart

ecscart is a module who can manage the caddy of an user. This module save the product reference, price and quantity.

The caddy has two states, valided or not valided. The caddy has the possibility to compute rules for the total amount, like reductions, taxes, delivery prices.

The computed caddy can be published as many format, like xml, json.

Finally the caddy will be persistant in database, to ensure data integrity during a crash.

Launching the cart

A few initialisation procedure is mandatory to instatiate the Cart class.

>>> from ecs.cart import Cart
>>> user_id = 'Doriane'
>>> cart = Cart(user_id)

Adding a product in the caddy

To add a product into the caddy we must use the add_product method. The first parameters is the reference of the product, the second the price, and the optional quantity parameters.

>>> cart.add_product('brosse a cheveux', 12.4)
>>> cart.add_product('lime a ongle', price=3.32, quantity=5)

Set quantity of the product

You can eventualy change the quantity of a product in a cart by the set_quantity method.

>>> cart.get_product_property('brosse a cheveux', 'quantity')
1.0
>>> cart.set_quantity('brosse a cheveux', 2)
>>> cart.get_product_property('brosse a cheveux', 'quantity')
2.0

Delete a product

You can delete a product by setting his quantity to 0, or most symply with the del_product method.

>>> cart.add_product('fond de teint', 19)
>>> cart.add_product('mascara', 12)
...
>>> cart.set_quantity('fond de teint', 0)
>>> cart.del_product('mascara')
...
>>> cart.get_product_property('fond de teint', 'price')
Traceback (most recent call last):
...
ValueError: Invalid reference fond de teint
>>> cart.get_product_property('mascara', 'quantity')
Traceback (most recent call last):
...
ValueError: Invalid reference mascara

Getting the amount of the caddy

It’s symply to have the amount of the caddy using the get_cart_amount

>>> amount = cart.get_cart_amount()
>>> round(amount)
41.0

Add reductions

You could add reduction on the cart.

>>> cart.add_reduction(5)
>>> amount = cart.get_cart_amount()
>>> round(amount)
36.0

You could delete the reduction

Confirm the caddy

A flag is provided to manage is the caddy is valided. The validation method is also provided validation can take a parameters wich will be the flag value:

>>> cart.validation_statut
False
>>> cart.validation()
>>> cart.validation_statut
True
>>> cart.validation('Not yet')
>>> cart.validation_statut
'Not yet'

Removing a caddy for an user

To delete the caddy from the persistence you must use the remove method

>>> cart.remove()
>>> cart.products
{}

Project details


Download files

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

Source Distribution

ecs.cart-0.3dev.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

ecs.cart-0.3dev-py2.5.egg (23.6 kB view details)

Uploaded Egg

File details

Details for the file ecs.cart-0.3dev.tar.gz.

File metadata

  • Download URL: ecs.cart-0.3dev.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ecs.cart-0.3dev.tar.gz
Algorithm Hash digest
SHA256 17f4d6aa71c860dc77b60e4b12f9db3ded262eb0ae5760d7072fba9c2b047138
MD5 faf6b79b8f9fa2852fa74995e5a3f7fb
BLAKE2b-256 fc3b4683966dba09ee9e53ab347ed6f275737a941654989493dc283fc02854b5

See more details on using hashes here.

File details

Details for the file ecs.cart-0.3dev-py2.5.egg.

File metadata

  • Download URL: ecs.cart-0.3dev-py2.5.egg
  • Upload date:
  • Size: 23.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ecs.cart-0.3dev-py2.5.egg
Algorithm Hash digest
SHA256 df6cb411f4657f0e2e37b53f0a241b4445eb8e6a2eee8ac4c2b9a4935b95ed2f
MD5 50d308c5f8046d4a4c1f1f0ea6118f4b
BLAKE2b-256 73f3226cb8d52132844500946e5c03c700b69e674773652e277355f64ad73d94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page