Community Documentation

Commerce Discount

Last updated July 31, 2012. Created by Amitaibu on July 31, 2012.
Edited by itamar. Log in to edit this page.

Overview

Commerce Discount - Adds the commerce module the ability to handle discounts.

The UI (Under admin/commerce/store/discounts) allows creating and editing discounts. Each discount consists of two entities, a commerce_discount, i.e. "Order Discount" or "Product Discount", and a “Commerce discount offer”, I.e. "$ off" or "% off". When creating a discount, a rule is generated for doing the actual price reduction.
For order discounts, the rule is attached to the commerce_order_presave event.
For product discounts, the event is commerce_product_calculate_sell_price, which
is fired every time a product's price is displayed.
The action fired by these events is either commerce_discount_fixed_amount or commerce_discount_percentage, depending on the offer type. When commerce_discount_fixed_amount called for an order discount, in case the discount wasn't applied to the order yet, it creates a new line item representing the discount and adds it to the order.
When it's called for a product discount, and the discount wasn't applied to it yet, it adds a component to the product price, on the line-item, representing the discount.
commerce_discount_percentage is adding price components (either to all of the order's line items, or for a line item of a specific product) with the discount converted to an absolute number.

Sub-modules

Commerce Discount Date

Adds commerce discount the ability to make a discount applicable only between certain dates. Works by adding a condition to the generated discount rule, verifying that the current data is in between the dates defined on the discount

Commerce Discount Usage

Adds the ability to make a certain discount applicable only a certain amount of times. Works by adding a field to the discount, tracking how many times it was used and by adding condition checking the current discount usage against the defined maximal usage.
The usage count is incremented when an order is created and when a discounted product is added to cart, and is decremented when an order gets deleted and when a product is removed from the cart.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Programmers
Level
Intermediate
Keywords
Commerce

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here