shuup.discounts package

Submodules

shuup.discounts.apps module

class shuup.discounts.apps.AppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.discounts'
provides = {'admin_module': ['shuup.discounts.admin.modules.DiscountModule', 'shuup.discounts.admin.modules.DiscountArchiveModule', 'shuup.discounts.admin.modules.AvailabilityExceptionModule', 'shuup.discounts.admin.modules.HappyHourModule', 'shuup.discounts.admin.modules.CouponCodeModule'], 'discount_module': ['shuup.discounts.modules:ProductDiscountModule'], 'order_source_modifier_module': ['shuup.discounts.modules:CouponCodeModule'], 'xtheme_plugin': ['shuup.discounts.plugins:DiscountedProductsPlugin']}
ready()[source]

shuup.discounts.exceptions module

exception shuup.discounts.exceptions.DiscountM2MChangeError[source]

Bases: Exception

shuup.discounts.modules module

class shuup.discounts.modules.ProductDiscountModule[source]

Bases: shuup.core.pricing.DiscountModule

identifier = 'product_discounts'
name = 'Product Discounts'
discount_price(context, product, price_info)[source]
class shuup.discounts.modules.CouponCodeModule[source]

Bases: shuup.core.order_creator.OrderSourceModifierModule

identifier = 'discounts_coupon_codes'
name = 'Product Discounts Coupon Codes'
can_use_code(order_source, code)[source]
use_code(order, code)[source]
clear_codes(order)[source]

shuup.discounts.plugins module

class shuup.discounts.plugins.ProductSelectionConfigForm(**kwargs)[source]

Bases: shuup.xtheme.plugins.forms.GenericPluginForm

A configuration form for the DiscountedProductsPlugin

populate()[source]

A custom populate method to display product choices

clean()[source]

A custom clean method to transform selected discounts into a list of ids

base_fields = OrderedDict()
declared_fields = OrderedDict()
media
class shuup.discounts.plugins.DiscountedProductsPlugin(config)[source]

Bases: shuup.xtheme.TemplatedPlugin

Instantiate a Plugin with the given config dictionary.

Parameters:config (dict) – Dictionary of freeform configuration data
identifier = 'discount_product'
name = 'Discounted Products'
template_name = 'shuup/discounts/product_discount_plugin.jinja'
editor_form_class

alias of ProductSelectionConfigForm

fields = [('title', <shuup.xtheme.plugins.forms.TranslatableField object>), ('count', <django.forms.fields.IntegerField object>), ('orderable_only', <django.forms.fields.BooleanField object>)]
get_context_data(context)[source]

shuup.discounts.settings module

shuup.discounts.settings.SHUUP_DISCOUNTS_PER_PRODUCT_EXPIRATION_DATES = False

Whether the price expiration should be calculated per product instead of per shop

shuup.discounts.signal_handers module

shuup.discounts.signal_handers.handle_discount_post_save(sender, instance, **kwargs)[source]
shuup.discounts.signal_handers.handle_happy_hour_post_save(sender, instance, **kwargs)[source]
shuup.discounts.signal_handers.handle_time_range_post_save(sender, instance, **kwargs)[source]
shuup.discounts.signal_handers.handle_availability_exception_post_save(sender, instance, **kwargs)[source]
shuup.discounts.signal_handers.handle_coupon_post_save(sender, instance, **kwargs)[source]
shuup.discounts.signal_handers.handle_generic_m2m_changed(sender, instance, **kwargs)[source]

As instance can be an instance of the sender or of the class the ManyToManyField is related to, we need to check the type of the instance and forward to the correct handler

shuup.discounts.utils module

shuup.discounts.utils.get_potential_discounts_for_product(context, product, available_only=True)[source]

Get a queryset of all possible discounts for a given context and product

If available_only is True, only the discounts which match
happy hours, availability exceptions and start/end dates will be returned
If available_only is False, all discounts that match with the context and product,
that are active will be returned.
shuup.discounts.utils.get_active_discount_for_code(order_or_order_source, code)[source]
shuup.discounts.utils.get_next_dates_for_range(weekday, from_hour, to_hour)[source]

Get datetime ranges for the next weekday

Example:
Give me the date ranges for the next Sunday from 1pm to 10pm It will return a tuple of datetimes.
If the requested weekday is the same of today, it will return both the ranges for today
and also for the next week.

:rtype list[datetime.datetime]

shuup.discounts.utils.bump_price_expiration(shops)[source]

Bump price expiration cache for shops

Parameters:shops (itetable[int|Shop]) – list of shops to bump caches
shuup.discounts.utils.get_price_expiration(context, product)[source]

Returns the price expiration for the product through a UNIX timestamp

This routine loads all dates that can possibly affect the price of the product in the future.

After fetching all the event dates, the expiration time will

be the minimum datetime that is greater than now:

expire_on = min(
event_date for event_dates in [
next_discount_start, next_discount_ends, next_happy_hour_start, next_happy_hour_end, next_availability_exception_start, next_availability_exception_end

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/latest/shuup/discounts/utils.py:docstring of shuup.discounts.utils.get_price_expiration, line 16)

Definition list ends without a blank line; unexpected unindent.

] if event_date > now

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/latest/shuup/discounts/utils.py:docstring of shuup.discounts.utils.get_price_expiration, line 18)

Definition list ends without a blank line; unexpected unindent.

)

:rtype numbers.Number|None :returns the price expiration time timestamp

Module contents