pmpro-register-helper icon indicating copy to clipboard operation
pmpro-register-helper copied to clipboard

Select2 script and style not enqueued if level parameter not present

Open ipokkel opened this issue 3 years ago • 1 comments

Describe the bug A select2 Register Helper field type is rendered as a multi-select field and the console has a javascript error notification of select2 not being a valid function when there is no level URL parameter.

We should consider additional conditional checks if the user is on the checkout page to load the required CSS & JS here:

https://github.com/strangerstudios/pmpro-register-helper/blob/2780df68cde584b5087ad7b508aa68a84494046c/pmpro-register-helper.php#L1338-L1352

To Reproduce Steps to reproduce the behavior:

  1. Create a select2 RH field in a customization plugin.
  2. Navigate to the membership levels page and select any level
  3. Confirm on the checkout page that the select2 field is rendered as expected.
  4. Remove URL parameter level, e.g. level=1, and load page
  5. Confirm that the select2 field is rendered as a multi-select field type
  6. Open the browser's developer tools and confirm that select2 CSS and JS files are not loaded.

Screenshots If applicable, please attach a screenshot to make your issue clearer.

Expected behavior A clear and concise description of what you expected to happen.

Isolating the problem (mark completed items with an [x]):

  • [x] I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
  • [x] This bug happens with a default WordPress theme active, or Memberlite.
  • [x] I can reproduce this bug consistently using the steps above.

ipokkel avatar Sep 03 '21 12:09 ipokkel