shoop.core.templatetags package

Submodules

shoop.core.templatetags.prices module

Template tags for displaying prices correctly.

Prefer these filters for rendering prices of products and basket lines or total price of basket, since the will take price display options of current template context into account (see PriceDisplayOptions). Especially, they convert prices to correct taxness.

There is also a global context function show_prices which can be used to render certain price container elements conditionally.

shoop.core.templatetags.prices.show_prices(context)[source]

Return true if price display options has show prices enabled.

shoop.core.templatetags.shoop_common module

Common helpers for Shoop templates.

Note

In addition to these, also the price rendering tags from shoop.core.templatetags.prices module are available.

shoop.core.templatetags.shoop_common.get_language_choices()[source]

Get language choices as code and text in two languages.

Returns:Available language codes as tuples (code, name, local_name) where name is in the currently active language, and local_name is in the language of the item.
Return type:Iterable[tuple[str,str,str]]
shoop.core.templatetags.shoop_common.money(amount, digits=None, widen=0)[source]

Format money amount according to current locale settings.

Parameters:
  • amount (shoop.utils.money.Money) – Money or Price object to format
  • digits (int|None) – Number of digits to use, by default use locale’s default
  • widen (int) – Number of extra digits to add; for formatting with additional precision, e.g. widen=3 will use 5 digits instead of 2
Returns:

Formatted string representing the given amount

Return type:

str

shoop.core.templatetags.shoop_common.percent(value, ndigits=0)[source]
shoop.core.templatetags.shoop_common.number(value)[source]
shoop.core.templatetags.shoop_common.datetime(value, kind='datetime', format='medium', tz=True)[source]

Format a datetime for human consumption.

The currently active locale’s formatting rules are used. The output of this function is probably not machine-parseable.

Parameters:
  • value (datetime.datetime) – datetime object to format
  • kind (str) – Format as ‘datetime’, ‘date’ or ‘time’
  • format (str) – Format specifier or one of ‘full’, ‘long’, ‘medium’ or ‘short’
  • tz (bool|str) –

    Convert to current or given timezone. Accepted values are:

    True (default)
    convert to currently active timezone (as reported by django.utils.timezone.get_current_timezone)
    False (or other false value like empty string)
    do no convert to any timezone (use UTC)
    Other values (as str)
    convert to given timezone (e.g. "US/Hawaii")
shoop.core.templatetags.shoop_common.json(value)[source]

Module contents