shuup.discounts package
Subpackages
- shuup.discounts.admin package
- Subpackages
- shuup.discounts.admin.modules package
- shuup.discounts.admin.views package
- Module contents
ArchivedDiscountListViewDiscountDeleteViewDiscountEditViewDiscountListViewDiscountListView.default_columnsDiscountListView.format_end_datetimeDiscountListView.get_discount_effectDiscountListView.get_querysetDiscountListView.mass_actionsDiscountListView.mass_actions_provider_keyDiscountListView.modelDiscountListView.toolbar_buttons_provider_keyDiscountListView.url_identifier
HappyHourEditViewHappyHourDeleteViewHappyHourListView
- Module contents
- Submodules
- shuup.discounts.admin.mass_actions module
- shuup.discounts.admin.widgets module
- Module contents
- Subpackages
- shuup.discounts.models package
- Module contents
HappyHourDiscountDiscount.DoesNotExistDiscount.MultipleObjectsReturnedDiscount.activeDiscount.categoryDiscount.category_idDiscount.cleanDiscount.contactDiscount.contact_groupDiscount.contact_group_idDiscount.contact_idDiscount.created_byDiscount.created_by_idDiscount.created_onDiscount.discount_amount_valueDiscount.discount_percentageDiscount.discounted_price_valueDiscount.end_datetimeDiscount.exclude_selected_categoryDiscount.get_next_by_created_onDiscount.get_next_by_modified_onDiscount.get_previous_by_created_onDiscount.get_previous_by_modified_onDiscount.happy_hoursDiscount.idDiscount.identifierDiscount.modified_byDiscount.modified_by_idDiscount.modified_onDiscount.nameDiscount.objectsDiscount.productDiscount.product_idDiscount.saveDiscount.shopDiscount.shop_idDiscount.shop_products_linkDiscount.start_datetimeDiscount.supplierDiscount.supplier_id
TimeRangeShopProductCatalogDiscountsLinkShopProductCatalogDiscountsLink.DoesNotExistShopProductCatalogDiscountsLink.MultipleObjectsReturnedShopProductCatalogDiscountsLink.discountsShopProductCatalogDiscountsLink.idShopProductCatalogDiscountsLink.objectsShopProductCatalogDiscountsLink.shop_productShopProductCatalogDiscountsLink.shop_product_id
- Module contents
Submodules
shuup.discounts.apps module
- class shuup.discounts.apps.AppConfig(*args, **kwargs)[source]
Bases:
AppConfig- name = 'shuup.discounts'
- default_auto_field = 'django.db.models.BigAutoField'
- provides = {'admin_module': ['shuup.discounts.admin.modules.DiscountModule', 'shuup.discounts.admin.modules.DiscountArchiveModule', 'shuup.discounts.admin.modules.HappyHourModule'], 'admin_object_selector': ['shuup.discounts.admin.object_selector.DiscountAdminObjectSelector'], 'discount_module': ['shuup.discounts.modules:ProductDiscountModule'], 'xtheme_plugin': ['shuup.discounts.plugins:DiscountedProductsPlugin']}
See /provides for details about the
providesvariable.
shuup.discounts.exceptions module
shuup.discounts.modules module
- class shuup.discounts.modules.ProductDiscountModule[source]
Bases:
DiscountModule- identifier = 'product_discounts'
- name = 'Product Discounts'
- discount_price(context, product, price_info)[source]
Discount given price of given product. :param context: Pricing context to operate in :param product: Product in question or its id :param price_info: Price to discount :return: A new instance of a discounted price
- index_shop_product(shop_product: ShopProduct | int, **kwargs)[source]
Index the shop product discounts. This is a heavy procedure, use with precaution and through some background task.
shuup.discounts.plugins module
- class shuup.discounts.plugins.ProductSelectionConfigForm(**kwargs)[source]
Bases:
GenericPluginFormA configuration form for the DiscountedProductsPlugin
- base_fields = {}
- declared_fields = {}
- property media
Return all media required to render the widgets on this form.
- class shuup.discounts.plugins.DiscountedProductsPlugin(config)[source]
Bases:
TemplatedPluginInstantiate a Plugin with the given
configdictionary.- 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, groups_ids=None, all_contacts=False)[source]
Get a queryset of all possible discounts for a given context and product
- If
available_onlyis True, only the discounts which match happy hours, start/end dates will be returned
- If
available_onlyis 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(shop_ids: Iterable[int])[source]
Bump price expiration cache for shop ids
- 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,
] if event_date > now
)
:rtype numbers.Number|None :returns the price expiration time timestamp
Index all shop products that are affected by the given discounts