Skip to content

Enables participant-specific pricing by adding Participant Type conditions to price fields

License

Notifications You must be signed in to change notification settings

Skvare/com.skvare.priceconditionfields

Repository files navigation

Price Condition Fields Extension

A CiviCRM extension that enables participant-specific pricing through a configuration-driven, server-side approach. This extension eliminates the need for fragile JavaScript/CSS manipulations by providing clean, maintainable participant type conditions on price fields.

Overview

Instead of using JavaScript to hide/show price fields based on participant type, this extension implements a server-side solution that:

  • Adds a "Participant Type" configuration option when creating price fields
  • Controls field visibility during event registration form rendering
  • Supports three participant type conditions:
    • All Participants - Field visible to all participants (default)
    • Primary Participant Only - Field only visible to the first/primary participant
    • Additional Participant Only - Field only visible to secondary participants

Features

Configuration-Driven

  • Admins configure participant type constraints when setting up price fields
  • No code changes required to implement different pricing strategies
  • Works across all event types without modification

Server-Side Processing

  • Price field visibility is determined server-side during form rendering
  • Fields are filtered at the buildAmount hook, ensuring consistency
  • No reliance on client-side logic that can be bypassed or break

Installation

  1. Copy the extension directory to your CiviCRM extensions directory:

    cp -r com.skvare.priceconditionfields /path/to/civicrm/extensions/
  2. Enable the extension through the CiviCRM UI:

    • Navigate to Administer > System Settings > Extensions
    • Find "Price Condition Fields" and click Install

Usage

Setting Up Participant-Specific Pricing

Step 1: Create/Edit a Price Set

  1. Navigate to Administer > CiviEvent > Price Sets
  2. Create or edit a price set
  3. Add a price field
  4. Then edit the price field to configure participant type conditions

Step 2: Configure Participant Type Condition

When editing a price field, you'll see a new dropdown:

Participant Type:

  • All Participants (default) - Everyone can see this field
  • Primary Participant Only - Only the first participant sees this field
  • Additional Participant Only - Only secondary participants see this field

Step 3: Assign to Event

Assign the price set to your event as usual. The extension handles the rest.

Example Scenarios

Scenario 1: Event with Base Fee + Shirt Sizing

  • Price Field 1 (Event Base Fee): All Participants
    • Charged to every participant
  • Price Field 2 (Shirt Size): Primary Participant Only
    • Ordered once for entire group, or additional cost only at primary level

Scenario 2: Discounted Registrations

  • Price Field 1 (Full Price): Primary Participant
    • Full price for first participant
  • Price Field 2 (Group Rate): Additional Participant
    • Discounted rate for additional participants in same registration

Hook Implementation

hook_civicrm_buildForm

Adds the "Participant Type" dropdown to the Price Field form (CRM_Price_Form_Field)

hook_civicrm_postProcess

Saves the participant type condition to the database when a price field is saved

hook_civicrm_buildAmount

Filters price fields during form rendering based on:

  • Current participant type (detected from form context)
  • Configured participant type conditions on each price field

Compatibility

  • CiviCRM: 5.81+
  • Drupal: 10, 11 (with CiviCRM module)
  • WordPress: 5.0+ (with CiviCRM plugin)
  • PHP: 8.3+

Support and Contributing

Credits

Developed by Skvare, LLC for the CiviCRM community.

About Skvare

Skvare LLC specializes in CiviCRM development, Drupal integration, and providing technology solutions for nonprofit organizations, professional societies, membership-driven associations, and small businesses. We are committed to developing open source software that empowers our clients and the wider CiviCRM community.

Contact Information:

Support

Contact us for support or to learn more.

About

Enables participant-specific pricing by adding Participant Type conditions to price fields

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published