2
  1. Added a Price Set. enter image description here
  2. Go to Contribution Page and the Receipt Email shows all the Price Set Items but along with it also shows Contribution Amount.

    Before Adding defaultPriceSet from the above-mentioned method the $lineitem array structure is as given below

[line_item] => Array
        (
            [5] => Array
                (
                    [25] => Array
                        (
                            [price_field_id] => 9
                            [price_field_value_id] => 25
                            [label] => Guidebook 1 Cooktown to Gunnawarra
                            [field_title] => guidebook selection
                            [description] => 
                            [qty] => 1
                            [unit_price] => 30.000000000
                            [line_total] => 30
                            [participant_count] => 0
                            [max_value] => 
                            [membership_type_id] => 
                            [membership_num_terms] => 
                            [auto_renew] => 
                            [html_type] => CheckBox
                            [financial_type_id] => 5
                            [tax_amount] => 0
                            [non_deductible_amount] => 0.00
                            [tax_rate] => 0.00000000
                        )
                [32] => Array
                    (
                        [price_field_id] => 10
                        [price_field_value_id] => 32
                        [label] => Up to 125 g (Weekenders)
                        [field_title] => Postage and Handling
                        [description] => 
                        [qty] => 1
                        [unit_price] => 5.000000000
                        [line_total] => 5
                        [participant_count] => 0
                        [max_value] => 
                        [membership_type_id] => 
                        [membership_num_terms] => 
                        [auto_renew] => 
                        [html_type] => Select
                        [financial_type_id] => 5
                        [tax_amount] => 0
                        [non_deductible_amount] => 0.00
                        [tax_rate] => 0.00000000
                    )


               [74] => Array
                    (
                        [price_field_id] => 21
                        [price_field_value_id] => 74
                        [label] => Cap
                        [field_title] => Cap
                        [description] => 
                        [qty] => 1
                        [unit_price] => 20.000000000
                        [line_total] => 20
                        [participant_count] => 0
                        [max_value] => 
                        [membership_type_id] => 
                        [membership_num_terms] => 
                        [auto_renew] => 
                        [html_type] => Text
                        [financial_type_id] => 5
                        [tax_amount] => 0
                        [non_deductible_amount] => 0.00
                        [tax_rate] => 0.00000000
                    )

                [75] => Array
                    (
                        [price_field_id] => 22
                        [price_field_value_id] => 75
                        [label] => BNT Sticker
                        [field_title] => BNT Sticker
                        [description] => 
                        [qty] => 2
                        [unit_price] => 4.000000000
                        [line_total] => 8
                        [participant_count] => 0
                        [max_value] => 
                        [membership_type_id] => 
                        [membership_num_terms] => 
                        [auto_renew] => 
                        [html_type] => Text
                        [financial_type_id] => 5
                        [tax_amount] => 0
                        [non_deductible_amount] => 0.00
                        [tax_rate] => 0.00000000
                    )

                [76] => Array
                    (
                        [price_field_id] => 23
                        [price_field_value_id] => 76
                        [label] => Badge/Hat Pin
                        [field_title] => Badge/Hat Pin
                        [description] => 
                        [qty] => 2
                        [unit_price] => 10.000000000
                        [line_total] => 20
                        [participant_count] => 0
                        [max_value] => 
                        [membership_type_id] => 
                        [membership_num_terms] => 
                        [auto_renew] => 
                        [html_type] => Text
                        [financial_type_id] => 5
                        [tax_amount] => 0
                        [non_deductible_amount] => 0.00
                        [tax_rate] => 0.00000000
                    )

            )

After adding defaultPriceSet it adds New Line Item which is as given below

(
    [1] => Array
        (
            [setID] => 1
            [priceFieldID] => 1
            [name] => contribution_amount
            [label] => Contribution Amount
            [priceFieldValueID] => 1
            [membership_type_id] => 
            [amount] => 1.000000000
            [financial_type_id] => 1
        )

)

How to get rid of this line item as it seems to show that user is charged twice as seen in below screenshot of email receipt Ignore the price value ,just look into the Contribution Amount row the total of which is same as the total of other items in the table so I need to exclude Contribution Amount from the table of Receipt,what is the correct way to remove that.? enter image description here

  1. I debugged and found that code under CRM/Price/BAO/PriceSet CRM_Price_BAO_PriceSet has a method which adds the row in the line item getDefaultPriceSet. This method generates the Contribution Amount array, how to skip this so Email Receipt looks clean?

where when I use a Price Set with multiple values

checkbox values Material A $20.

select list Material B $30

textfield with quantity Material C:- 1 * $20 = $20 the Receipt it prints has following rows Material A . $20
Contribution Amount $70 (which is total of $20 + $30+ $20)
Material B . $30
Material C $20

(edited) For a user point of view this looks very confusing
as Material A, Material B and Material C is already listed and . it does
not make sense to print Contribution Amount I am using Civicrm 5.13.4 version

2

You can edit the contribution receipt under Mailings menu » Message Templates, System Workflow Messages tab. You can insert a conditional in the Smarty to exclude a line based on one or more variables in it. E.g. in the Online Receipt, the Smarty that generates the line items is pasted below. You could put {if $line.description eq 'Contribution Amount'} just under the foreach with a closing tag at the bottom and it should omit this line.

{foreach from=$value item=line}
            <tr>
             <td>
             {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
             </td>
             <td>
              {$line.qty}
             </td>
             <td>
              {$line.unit_price|crmMoney:$currency}
             </td>
             {if $getTaxDetails}
              <td>
               {$line.unit_price*$line.qty|crmMoney:$currency}
              </td>
              {if $line.tax_rate != "" || $line.tax_amount != ""}
               <td>
                {$line.tax_rate|string_format:"%.2f"}%
               </td>
               <td>
                {$line.tax_amount|crmMoney:$currency}
               </td>
              {else}
               <td></td>
               <td></td>
              {/if}
             {/if}
             <td>
              {$line.line_total+$line.tax_amount|crmMoney:$currency}
             </td>
            </tr>
           {/foreach}
          </table>
         </td>
        </tr>
       {/foreach}
  • Thanks a lot for the answer, I am aware of this method, but I was rather looking into the reason for the "Contribution Amount" added in the line item as we actually don't have anything in the price set which should display it on the line item. If you can help me debug it and fix it it would be helpful so we reach to an ideal solution. – harshal Jun 29 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.