134 lines
4.2 KiB
Markdown
134 lines
4.2 KiB
Markdown
# DigressivePrice
|
|
|
|
Easily create and manage range of quantities with associated discounts.
|
|
|
|
## Installation
|
|
|
|
**Warning** : to get real time changes of digressive prices on the product page, you have to use Thelia 2.4,
|
|
or replace in thelia.js :
|
|
|
|
`$pse.id.val(pseId);`
|
|
|
|
with
|
|
|
|
`$pse.id.val(pseId).trigger('change.pse', pseId);`
|
|
|
|
|
|
### Manually
|
|
|
|
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is DigressivePrice.
|
|
* Activate it in your thelia administration panel
|
|
|
|
### Composer
|
|
|
|
Add it in your main thelia composer.json file
|
|
|
|
```
|
|
composer require thelia/digressiveprice-module:~1.0
|
|
```
|
|
|
|
## Usage
|
|
|
|
Once activated, go into the Digressive Prices tab of the product you want to add a digressive price to.
|
|
You can create a new range, edit or remove an existing one.
|
|
Fill the form with following information :
|
|
|
|
- Quantity
|
|
- from : the quantity which begins your range
|
|
- to : the quantity that ends you range.
|
|
- Discount in %
|
|
|
|
Then click the "Add" or "Update" button.
|
|
|
|
Take care of the following :
|
|
|
|
- "quantity to" has to be greater than or equal to "quantity from"
|
|
- a quantity ('from' and/or 'to') can't be included into another range
|
|
- a range can't surround another one
|
|
- a quantity can't be negative
|
|
|
|
Once created, a table of digressive price is displayed on the product page. This table is updated when the PSE is changed.
|
|
|
|
The price will be automatically updated according to the product's quantity in the user's cart.
|
|
|
|
## Hook
|
|
|
|
This module is only hooked into the Modules tab of the products.
|
|
The Hook used is called "product.tab-content".
|
|
|
|
On the front-offcie, the module uses the `product.details-bottom` and `product.javascript-initialization` hooks.
|
|
|
|
## Loop
|
|
|
|
[digressive]
|
|
|
|
### Input arguments
|
|
|
|
|Argument |Description |
|
|
|--- |--- |
|
|
|**product_id** | The ID of the product to get digressive prices. Example: "product_id=3" |
|
|
|
|
### Output arguments
|
|
|
|
|Variable |Description |
|
|
|--- |--- |
|
|
|$ID | The digressive price range's ID |
|
|
|$PRODUCT_ID | The product which th current digressive price is linked to |
|
|
|$QUANTITY_FROM | The quantity beginning of the range of the digressive price |
|
|
|$QUANTITY_TO | The quantity ending of the range of the digressive price |
|
|
|$DISCOUNT | The discount % |
|
|
|$PRICE | The tax free price of the product if the quantity is in the range |
|
|
|$PROMO_PRICE | The promo tax free price of the product if the quantity is in the range |
|
|
|$TAXED_PRICE | The taxed price of the product. Uses the tax rules of the user's country |
|
|
|$TAXED_PROMO_PRICE | The taxed promo price of the product. Uses the tax rules of the user's country |
|
|
|
|
### Example
|
|
|
|
This example displays the product prices according to all the quantity's ranges
|
|
|
|
```html
|
|
<table>
|
|
<tr>
|
|
<th>Quantity</th>
|
|
<th>Unit Price (with taxes)</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>1</td>
|
|
<td>
|
|
{if $IS_PROMO==1}
|
|
{$BEST_TAXED_PRICE} {currency attr="symbol"} <del>{$TAXED_PRICE} {currency attr="symbol"}</del>
|
|
{else}
|
|
{$TAXED_PRICE} {currency attr="symbol"}
|
|
{/if}
|
|
</td>
|
|
</tr>
|
|
|
|
{loop type="product" name="theProduct" id={product attr="id"}}
|
|
{if $IS_PROMO==1}
|
|
{loop type="digressive" name="digressivePrice" product_id=$ID}
|
|
<tr>
|
|
{if $QUANTITY_FROM != 0 && $QUANTITY_TO == 99999}
|
|
<td>From {$QUANTITY_FROM}</td>
|
|
{else}
|
|
<td>From {$QUANTITY_FROM} to {$QUANTITY_TO}</td>
|
|
{/if}
|
|
<td>{$TAXED_PROMO_PRICE} {currency attr="symbol"}</td>
|
|
</tr>
|
|
{/loop}
|
|
{else}
|
|
{loop type="digressive" name="digressivePrice" product_id=$ID}
|
|
<tr>
|
|
{if $QUANTITY_FROM != 0 && $QUANTITY_TO == 99999}
|
|
<td>From {$QUANTITY_FROM}</td>
|
|
{else}
|
|
<td>From {$QUANTITY_FROM} to {$QUANTITY_TO}</td>
|
|
{/if}
|
|
<td>{$TAXED_PRICE} {currency attr="symbol"}</td>
|
|
<tr>
|
|
{/loop}
|
|
{/if}
|
|
{/loop}
|
|
</table>
|
|
```
|