<commit_before>Discounts
=========

Satchmo allows you to setup multiple types of discount codes:

 * Straight dollar amounts
 * Percentage off
 * Free shipping

Each of these types can be qualified or limited by:

 * Number of uses
 * Minimum order
 * Specific dates
 * Specific products

.. index::
   single: Discounts

Creating Discounts
------------------

A discount code is easy to setup in Satchmo using the following fields:

  :Description:
    A simple characterization of the discount.  For example, "New User Discount"
    or "Repeat Customer Promotion."

  :Code: The unique identifier a user would enter to activate this discount.

  :Amount:
    A straight dollar discount off a product.  You can only have a dollar OR
    percentage.

  :Percentage: A percent discount off the price.

  :Auto Discounts:
    Use this field to advertise the discount on all products to which it
    applies. Generally this is used for site-wide sales. See
    :ref:`auto-discounts` for details.

  :Allowed Uses: The number of times this discount can be applied.

  :Num Uses: The number of times this discount has been used.

  :Minimum Order:
    The minimum amount that must be purchased before this can
    apply.

  :Start Date: The date when this discount becomes effective.

  :End Date: The date when this discount is no longer valid.

  :Active:
    A flag you can set to make it active.  If you want to create a discount in
    advance but hold off on making it available, you can use this flag.

  :Free Shipping:
    Whether or not this discount allows the user to not have to pay shipping
    charges.

  :Include Shipping:
    A flag to determine if shipping costs should be affected by the discount.

  :Valid Products: A list of all the products this discount is valid for.

.. _auto-discounts:

Store Wide Sales via Auto Discounts
-----------------------------------

Automatic discounts are how you do store wide sales.

.. warning::
	Automatic discounts must always be percentage sales, and you can only have one running at a time. You should also ensure that you do not apply auto discounts to gift certificates.

1. In your site's admin interface, create a new discount.

2. Make an "automatic" discount, so that it is available to the automatic discount template tags. Do not enter a new price in the admin for the products.

3. In the template where you want to show the auto discount, load the ``{% satchmo_discounts %}`` (Visit `Satchmo Templates`_ documentation for details on Satchmo filters) filter library.

4. You can now add some markup to your template, similar to below::

	{% if sale %}
	<div>
		<div class="saleprices">
			<h3> Regular price: <span class="saleprice" id="price">{{product.unit_price|currency}}</span></h3>
	    	<h3> {{ sale.percentage_text }} off: <span class="saleprice" id="sale_saved">{{ product|discount_saved:"sale"|currency }}</span></h3>
	    	<h3> Your price: <span class="saleprice" id="sale_price">{{ product|discount_price:"sale"|currency }}</span></h3>
	{% else %}
		<h3 id="price">{{product.unit_price|currency}}</h3>
	</div>
	{% endif %}

The key parts of the above markup are the ``{{ product|discount_saved:"sale"|currency }}`` and the ``{{ product|discount_price:"sale"|currency }}`` filtered variables. The former returns the amount saved by the discount while the latter returns the discounted price, all in the correct locale currency.


.. _`Satchmo Templates`: templates.html
<commit_msg>docs/discounts: say 'site-wide sales'<commit_after>Discounts
=========

Satchmo allows you to setup multiple types of discount codes:

 * Straight dollar amounts
 * Percentage off
 * Free shipping

Each of these types can be qualified or limited by:

 * Number of uses
 * Minimum order
 * Specific dates
 * Specific products

.. index::
   single: Discounts

Creating Discounts
------------------

A discount code is easy to setup in Satchmo using the following fields:

  :Description:
    A simple characterization of the discount.  For example, "New User Discount"
    or "Repeat Customer Promotion."

  :Code: The unique identifier a user would enter to activate this discount.

  :Amount:
    A straight dollar discount off a product.  You can only have a dollar OR
    percentage.

  :Percentage: A percent discount off the price.

  :Auto Discounts:
    Use this field to advertise the discount on all products to which it
    applies. Generally this is used for site-wide sales. See
    :ref:`auto-discounts` for details.

  :Allowed Uses: The number of times this discount can be applied.

  :Num Uses: The number of times this discount has been used.

  :Minimum Order:
    The minimum amount that must be purchased before this can
    apply.

  :Start Date: The date when this discount becomes effective.

  :End Date: The date when this discount is no longer valid.

  :Active:
    A flag you can set to make it active.  If you want to create a discount in
    advance but hold off on making it available, you can use this flag.

  :Free Shipping:
    Whether or not this discount allows the user to not have to pay shipping
    charges.

  :Include Shipping:
    A flag to determine if shipping costs should be affected by the discount.

  :Valid Products: A list of all the products this discount is valid for.

.. _auto-discounts:

Site-wide Sales via Auto Discounts
----------------------------------

Automatic discounts are how you do side-wide sales.

.. warning::
	Automatic discounts must always be percentage sales, and you can only have one running at a time. You should also ensure that you do not apply auto discounts to gift certificates.

1. In your site's admin interface, create a new discount.

2. Make an "automatic" discount, so that it is available to the automatic discount template tags. Do not enter a new price in the admin for the products.

3. In the template where you want to show the auto discount, load the ``{% satchmo_discounts %}`` (Visit `Satchmo Templates`_ documentation for details on Satchmo filters) filter library.

4. You can now add some markup to your template, similar to below::

	{% if sale %}
	<div>
		<div class="saleprices">
			<h3> Regular price: <span class="saleprice" id="price">{{product.unit_price|currency}}</span></h3>
	    	<h3> {{ sale.percentage_text }} off: <span class="saleprice" id="sale_saved">{{ product|discount_saved:"sale"|currency }}</span></h3>
	    	<h3> Your price: <span class="saleprice" id="sale_price">{{ product|discount_price:"sale"|currency }}</span></h3>
	{% else %}
		<h3 id="price">{{product.unit_price|currency}}</h3>
	</div>
	{% endif %}

The key parts of the above markup are the ``{{ product|discount_saved:"sale"|currency }}`` and the ``{{ product|discount_price:"sale"|currency }}`` filtered variables. The former returns the amount saved by the discount while the latter returns the discounted price, all in the correct locale currency.


.. _`Satchmo Templates`: templates.html

{'fraction_non_alphanumeric': 0.09621201209851649, 'fraction_numerical': 0.0034567189975514907, 'mean_word_length': 3.6017229953611665, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '872391', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1848, 'n_words': 923}