Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-5288

Allow package option values to be non-unique for inactive values

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.11.0-b2
    • Component/s: None
    • Labels:
      None

      Description

      Currently option values must be unique, but it would be nice to be able to disable an option and replace it with a new one with the same price to replace it while keeping current users on the old price.

      In app/models/package_options.php around line 2271 change

          private function validateUniqueValues($values) {
              $option_values = [];
              foreach ((array)$values as $index => $value) {
                  if (isset($value['value']) && !isset($option_values[$value['value']])) {
                      $option_values[$value['value']] = $value['value'];
                  }
              }
      
              return count($option_values) === count((array)$values);
          }
      

      To

          private function validateUniqueValues($values) {
              $option_values = [];
              foreach ((array)$values as $index => $value) {
                  if (($value['status'] ?? null) == 'inactive') {
                      unset($values[$index]);
                  }
                  if (isset($value['value']) && !isset($option_values[$value['value']])) {
                      $option_values[$value['value']] = $value['value'];
                  }
              }
      
              return count($option_values) === count((array)$values);
          }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            abdy Abdy Franco
            Reporter:
            jonathan Jonathan Reissmueller
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 12 minutes
              12m

                Agile