1

The requirement is that if someone picks a complimentary part of the event they have to select a paid part.

I have updated with jquery the rule so that if someone checks a free option the corresponding paid for option is also checked. The price calculation update is not performed. How do I get the prices to update?

2

Here's how we do it:

We do the two sets of items in a separate price field on the same price set. So the paid options that are required would be in one field, the complementary in another (or several others). I set the price field for the required options to required. Then they are forced to choose one of them. We only have one item in the required section and one in the optional section, but you could have more.

This then forces them to choose the mandatory item every time. We had to do this because folks would select the optional item, the book, and not select the training registration as well.

Price fields in back-end

Price fields on page

1

I ended up using click rather than just setting checked. This enables more than one payable item to enable access to the 'free' items.

function ConferenceManager() {
var mgr = this;
mgr.bootcamp = jQuery('#price_4_4');
mgr.pioneerAwards = jQuery('#price_4_6');
mgr.mainConference = jQuery('#price_4_7');
mgr.specialistRoundTables = jQuery('#price_4_8');

// Main conference is checked by default, but bootcamp is not.
mgr.mainConferenceChecked = true; // mgr.mainConference.defaultChecked is undefined
mgr.bootcampChecked = false;
mgr.changing = false;

mgr.bootcamp.change(function () {
  if (mgr.changing) {
    mgr.changing = false;
  } else {
    if (document.getElementById('price_4_4').checked) {
      mgr.bootcampChecked = true;
    } else {
      mgr.bootcampChecked = false;
      if (!mgr.mainConferenceChecked) {
        mgr.pioneerAwards.prop('checked', false);
        mgr.specialistRoundTables.prop('checked', false);
      }
    }
  }
});

mgr.pioneerAwards.change(function () {
  if (this.checked) {
    // Main conference is checked
    if (!mgr.mainConferenceChecked && !mgr.bootcampChecked) {
      mgr.changing = true;
      mgr.mainConferenceChecked = true;
      mgr.mainConference.click();
    }
  }
});

mgr.mainConference.change(function () {
  if (mgr.changing) {
    mgr.changing = false;
  } else {
    if (document.getElementById('price_4_7').checked) {
      mgr.mainConferenceChecked = true;
    } else {
      mgr.mainConferenceChecked = false;
      if (!mgr.bootcampChecked) {
        mgr.pioneerAwards.prop('checked', false);
        mgr.specialistRoundTables.prop('checked', false);
      }
    }
  }
});

mgr.specialistRoundTables.change(function () {
  if (this.checked) {
    // Main conference is checked
    if (!mgr.mainConferenceChecked && !mgr.bootcampChecked) {
      mgr.changing = true;
      mgr.mainConferenceChecked = true;
      mgr.mainConference.click();
    }
  }
});
}

var conferenceManager = new ConferenceManager();

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.