shoop.front.basket package¶
Submodules¶
shoop.front.basket.command_dispatcher module¶
-
class
shoop.front.basket.command_dispatcher.BasketCommandDispatcher(request, basket=None)[source]¶ Bases:
objectBasketCommandDispatcher handles (usually AJAX) requests that somehow update the basket. You should never instantiate BasketCommandDispatcher yourself – instead use
get_basket_command_dispatcher().All
handle_*methods are expected to accept**kwargs.-
commands_module= <module 'shoop.front.basket.commands' from '/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/stable/doc/../shoop/front/basket/commands.py'>¶
-
handle(command, kwargs=None)[source]¶ Dispatch and handle processing of the given command.
Parameters: - command (unicode) – Name of command to run
- kwargs (dict) – Arguments to pass to the command handler. If empty,
request.POSTis used.
Returns: response
Return type: HttpResponse
-
preprocess_kwargs(command, kwargs)[source]¶ Preprocess kwargs before they are passed to the given
commandhandler. Useful for subclassing. Must return the newkwargs, even if it wasn’t mutated.Parameters: - command – The name of the command about to be run
- kwargs – dict of arguments
Returns: dict of arguments
-
postprocess_response(command, kwargs, response)[source]¶ Postprocess the response dictionary (not a HTTP response!) before it is either turned into JSON or otherwise processed (in the case of non-AJAX requests).
Parameters: - command – The command that was run.
- kwargs – The actual kwargs the command was run with.
- response – The response the command returned.
Returns: The response to be processed and sent to the client.
-
shoop.front.basket.commands module¶
-
shoop.front.basket.commands.handle_add(request, basket, product_id, quantity=1, supplier_id=None, **kwargs)[source]¶ Handle adding a product to the basket.
Parameters: - product_id – product ID to add (or if
child_product_idis truey, the parent ID) - quantity – quantity of products to add
- child_product_id – child product ID to add (if truey)
- supplier_id – The supplier ID for the new line. If None, the first supplier is used.
- product_id – product ID to add (or if
-
shoop.front.basket.commands.handle_add_var(request, basket, product_id, quantity=1, **kwargs)[source]¶ Handle adding a complex variable product into the basket by resolving the combination variables. This actually uses
kwargs, expectingvar_XXX=YYYto exist there, whereXXXis the PK of a ProductVariationVariable and YYY is the PK of a ProductVariationVariableValue. Confused yet?Parameters: - quantity – Quantity of the resolved variation to add.
- kwargs – Expected to contain
var_*values, see above.
-
shoop.front.basket.commands.handle_del(request, basket, line_id, **kwargs)[source]¶ Handle deleting a distinct order line from the basket given its unique line ID.
Parameters: line_id – The line ID to delete. Returns:
shoop.front.basket.objects module¶
-
class
shoop.front.basket.objects.BasketLine(source=None, **kwargs)[source]¶ Bases:
shoop.core.order_creator.SourceLine-
shop_product¶ ShopProduct object of this line.
Return type: shoop.core.models.ShopProduct
-
type¶
-
can_delete¶
-
can_change_quantity¶
-
-
class
shoop.front.basket.objects.BaseBasket(request, basket_name='basket')[source]¶ Bases:
shoop.core.order_creator.OrderSource-
save()[source]¶ Persist any changes made into the basket to storage.
One does not usually need to directly call this;
ShoopFrontMiddlewarewill usually take care of it.
-
finalize()[source]¶ Mark the basket as “completed” (i.e. an order is created/a conversion made).
This will also clear the basket’s data.
-
add_product(supplier, shop, product, quantity, force_new_line=False, extra=None, parent_line=None)[source]¶
-
orderable¶
-
shoop.front.basket.order_creator module¶
-
class
shoop.front.basket.order_creator.BasketOrderCreator(request=None)[source]¶ Bases:
shoop.core.order_creator.OrderCreatorInitialize order creator.
Parameters: request (django.http.HttpRequest|None) – Optional request object for backward compatibility. Passing non-None value is DEPRECATED.
shoop.front.basket.storage module¶
-
class
shoop.front.basket.storage.BasketStorage[source]¶ Bases:
object-
load(basket)[source]¶ Load the given basket’s data dictionary from the storage.
Return type: dict Raises: BasketCompatibilityErrorif basket loaded from the storage is not compatible with the requested basket.
-
-
class
shoop.front.basket.storage.DictStoredBasket(id, shop_id, currency, prices_include_tax, data)[source]¶ Bases:
object
-
shoop.front.basket.storage.get_storage()[source]¶ Retrieve a basket storage object.
Returns: A basket storage object Return type: BasketStorage
shoop.front.basket.update_methods module¶
-
class
shoop.front.basket.update_methods.BasketUpdateMethods(request, basket)[source]¶ Bases:
object-
get_prefix_to_method_map()[source]¶ Override this method to link prefixes with their associated methods to call.
Format of the dictionary is: { FIELD_NAME_PREFIX: METHOD }.
METHOD is a function which accepts the keyword arguments given in
update_basket_contents. It should perform the necessary changes to the basket_line and then return whether the value had changed or not. (Seeupdate_quantityordelete_linefor examples.)
-
Module contents¶
-
shoop.front.basket.get_basket_command_dispatcher(request)[source]¶ Return type: shoop.front.basket.command_dispatcher.BasketCommandDispatcher
-
shoop.front.basket.get_basket(request)[source]¶ Return type: shoop.front.basket.objects.BaseBasket