Shows the working of modifiers on plans and their costs.
Modifiers allow you to add additional costs to the plans subscribed by users. These additional costs are applied in the form of taxes or discounts you want to apply on the plan's cost.
There are 4 basic types of modifiers:

  1. Discountable Modifiers: These modifiers can be applied before the application of discount or tax modifiers.

  2. Discount Modifiers: These modifiers are applied only for additional discount application on the already existing plans.

  3. Taxable Modifiers: These modifiers are applied only for additional tax application on the already existing plans.

  4. Non-Taxable Modifiers: These modifiers can be applied after the application of tax or discount modifiers.

Every modifier consists of two more type of modifiers viz., Fixed Modifiers and Percentage Modifiers. Fixed Modifiers are always applied before Percentage Modifiers.

Understanding the Code:

Whenever you wish to apply a modifier, you are supposed to invoke a method to get the instance of the modifier. This can be done as:

$modifier = PayplansModifier::getInstance();

Next you are required to use certain parameters like:

Message: It is the message or text which can be set for display of some message.
Invoice Id: It is used to determine the the invoice on which you wish to apply the modifier.
User Id: You have to set id of the user who is using the invoice.
Type: Here you can set the type of modifier you want to apply on a certain plan.
Amount: It is to hold the numeric value which should be applied either as tax or discount (if any).
Reference: It is to mention the reference (like coupon code) of the modifier.
Percentage: It stores percentage value of the tax and discount which you want to apply on the plan.
Frequency: Here you can mention whether you want to apply the current modifier only on the present invoice or on all other upcoming invoices.
Serial: It contains the order in which the modifiers get applied on plans.

Also, you need to take two parameters namely, Fixed Discount and Percentage Discount. These are to determine the form of modifier which you want to apply i.e. whether the modifier should be applied in percentage or not.
Underwritten is the code demonstrating about the structure of the method used for working of modifiers.

$modifier = PayplansModifier::getInstance();
$modifier ->set('message',XiText::_('COM_PAYPLANS_APP_BASIC_DISCOUNT_MESSAGE'))
                ->set('invoice_id', $object-]getId())
                ->set('user_id', $object-]getBuyer())
                ->set('type', $this-]getType())
                ->set('amount', - $this ->getAppParam('coupon_amount', $amount)) // Discount should be negative
                ->set('reference', this->getAppParam('coupon_code', ''))
                ->set('percentage', $isPercentage ? true : false)
                ->set('frequency', this->getAppParam('onlyFirstRecurringDiscount', false) ? PayplansModifier::FREQUENCY_ONE_TIME : 
                            PayplansModifier::FREQUENCY_EACH_TIME);/** * V.V.IMP : this is very important for applying discount in which serial

            * @see PayplansModifier */
            $serial = ($isPercentage === true)? PayplansModifier::PERCENT_DISCOUNT: PayplansModifier::FIXED_DISCOUNT;
            // XITODO : add error checking
$modifier->set('serial', $serial)
  • Modifiers: Denotes the modifiers which are to be applied on the invoice

    • Subtotal: It defines the subtotal of the total amount which should be applied as tax or discount

    • Invoice_Number: It is to determine the invoice number on which the modifier should be applied

    • Frequency_Each_Time: It shows that the modifier should be applied on every upcoming invoice.

    • Frequency_One_Time: It shows that the modifier should be applied only on the current invoice.

    • Total: It holds the total amount which will be shown to user for payment purpose.

public function getTotalByFrequencyOnInvoiceNumber($modifiers, $subtotal, $invoiceNumber){
$total = $subtotal;
foreach($modifiers as $modifier){
    switch ($modifier-]getFrequency()){
    case PayplansModifier::FREQUENCY_EACH_TIME :
                $total = self::getTotal($total, $modifier);
    default :continue;
return $total;

The underwritten code shows the invocation of the method written for modifiers.

PayplansHelperModifier::getTotalByFrequencyOnInvoiceNumber($modifier, $subtotal, $number);