shuup.discounts package¶
Subpackages¶
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']}¶
-
shuup.discounts.exceptions module¶
shuup.discounts.modules module¶
-
class
shuup.discounts.modules.
ProductDiscountModule
[source]¶ Bases:
shuup.core.pricing.DiscountModule
-
identifier
= 'product_discounts'¶
-
name
= 'Product Discounts'¶
-
shuup.discounts.plugins module¶
-
class
shuup.discounts.plugins.
ProductSelectionConfigForm
(**kwargs)[source]¶ Bases:
shuup.xtheme.plugins.forms.GenericPluginForm
A configuration form for the DiscountedProductsPlugin
-
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>)]¶
-
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.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.
- If
-
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
] if event_date > now
)
:rtype numbers.Number|None :returns the price expiration time timestamp