Contribution amount not showing up on donation page when user not logged in, for non-priceset contributions
Overview
Donation form works as expected when a user is logged in, but does not provide donation amount fields when no user is logged in.
Discussion: https://chat.civicrm.org/civicrm/pl/469j6xwte7gnurechm4f8mm14r
Reproduction steps
- Create and publish a Contribution page not linked to a Price Set.
- Visit the resulting page when logged in to view correct behavior.
- Open a private browsing window to view as not-logged-in to observe the missing fields.
Current behaviour
HTML extract from the form, missing the expected fields:
<div id="priceset" class="crm-section price_set-section">
<div class="crm-section other_amount-section">
<div class="label"></div>
<div class="content other_amount-content">
</div>
<div class="clear"></div>
</div>
When fixed contribution amounts are also enabled:
<div id="priceset" class="crm-section price_set-section">
<div class="crm-section contribution_amount-section">
<div class="label"></div>
<div class="content contribution_amount-content">
</div>
<div class="clear"></div>
</div>
<div class="crm-section other_amount-section">
<div class="label"></div>
<div class="content other_amount-content">
</div>
<div class="clear"></div>
</div>
Expected behaviour
HTML extract from the logged-in form, containing the expected fields:
<div id="priceset" class="crm-section price_set-section">
<div class="crm-section other_amount-section">
<div class="label"><label for="price_8"> Donation Amount
<span class="crm-marker" title="This field is required.">*</span>
</label></div>
<div class="content other_amount-content">
<input price="[14,"1||"]" size="4" name="price_8" type="text" id="price_8" class="four crm-form-text required" />
</div>
<div class="clear"></div>
</div>
When fixed contribution amounts are also enabled:
<div id="priceset" class="crm-section price_set-section">
<div class="crm-section contribution_amount-section">
<div class="label"><label>Donation Amount</label></div>
<div class="content contribution_amount-content">
<div class="price-set-row contribution_amount-row1">
<span class="price-set-option-content"><input price="["price_9","10||"]" data-amount="10.000000000" data-currency="USD" data-price-field-values="{"15":{"id":"15","price_field_id":"9","amount":"10.000000000","weight":"1","is_default":"0","is_active":"1","financial_type_id":"1","non_deductible_amount":"0.00","visibility_id":"0"},"16":{"id":"16","price_field_id":"9","amount":"20.000000000","weight":"2","is_default":"0","is_active":"1","financial_type_id":"1","non_deductible_amount":"0.00","visibility_id":"0"}}" visibility="0" onclick="clearAmountOther();" value="15" type="radio" id="CIVICRM_QFID_15_2" name="price_9" class="crm-form-radio" /><label for="CIVICRM_QFID_15_2"><span class="crm-price-amount-label"></span><span class="crm-price-amount-amount">$ 10.00</span></label></span>
</div>
<div class="price-set-row contribution_amount-row2">
<span class="price-set-option-content"><input price="["price_9","20||"]" data-amount="20.000000000" data-currency="USD" data-price-field-values="{"15":{"id":"15","price_field_id":"9","amount":"10.000000000","weight":"1","is_default":"0","is_active":"1","financial_type_id":"1","non_deductible_amount":"0.00","visibility_id":"0"},"16":{"id":"16","price_field_id":"9","amount":"20.000000000","weight":"2","is_default":"0","is_active":"1","financial_type_id":"1","non_deductible_amount":"0.00","visibility_id":"0"}}" visibility="0" onclick="clearAmountOther();" value="16" type="radio" id="CIVICRM_QFID_16_4" name="price_9" class="crm-form-radio" /><label for="CIVICRM_QFID_16_4"><span class="crm-price-amount-label"></span><span class="crm-price-amount-amount">$ 20.00</span></label></span>
</div>
<div class="price-set-row contribution_amount-row3">
<span class="price-set-option-content"><input price="["price_9","0"]" value="0" type="radio" id="CIVICRM_QFID_0_6" name="price_9" class="crm-form-radio" /><label for="CIVICRM_QFID_0_6">Other Amount</label></span>
</div>
</div>
<div class="clear"></div>
</div>
<div class="crm-section other_amount-section">
<div class="label"><label for="price_8">Other Amount</label></div>
<div class="content other_amount-content">
<input price="[14,"1||"]" size="4" name="price_8" type="text" id="price_8" class="four crm-form-text" />
</div>
<div class="clear"></div>
</div>
Environment information
- Browser: observed on Firefox, Safari, Chrome
- CiviCRM: 5.26.1
- PHP: 7.3.17
- CMS: Drupal 7.71