The subject pretty much says it. Rather than only letting you select one product in the required product, it would be great if the required product pulldown let you select multiple products.

Even better, would be if it behaved like the Discount Application interface and had a Filter Type and then I could select individual products, product classes or taxonomy terms. That would be the ultimate!

Comments

ergophobe’s picture

I forgot to mention, this was original requested in #448624: Qualification based on products (list of SKUs), Single Product but it seemed better to open a new feature request for it

ergophobe’s picture

Ryan - I looked at the code. It doesn't look like this would be that complicated (famous last words), just a bit tedious, but it will probably take me a couple of weeks to get to it... but I do hope to create a patch for this pretty soon.

For the minimum, it would require one additional table (uc_discounts_required_products). For the ultimate, several (uc_discounts_required_classes, etc) and quite changing lots of queries.

ryangroe’s picture

Should be one more join and an IN statement, right? Ultimately it's more a matter of making sure all the code paths work rather than getting the concept to work.

Give a patch and shot and I, daveoxide or jrust will integrate. Thanks for your help!

ergophobe’s picture

Cool. It will take a few weeks what with current projects and various holiday stuff. Since I seem to be the only one who wants it, I figure there's no hurry.

If you guys weren't interested in folding in a patch like this (assuming it works well), I just didn't want to end up with a fork.

jrust’s picture

Sounds like we need Rules integration, but I don't think that's gonna happen anytime soon.

ergophobe’s picture

hmmm... can ask a possibly foolish question? What do you imagine the "event" (or events) would be that would trigger the rules. Add to cart? View cart????

Just confessing total ignorance here - I understand the *concept* of the Rules module, but close to nothing about it from a developer's perspective.

jrust’s picture

Yeah, good point, I don't think rules would work. It would just be nice if we had rules' flexible interface for making conditions. Did you make any headway on it?

ergophobe’s picture

Sorry... no, I got sidetracked and had to do some sort of ugly hardcoded hacks to get the site launched by deadline, but finally it seems most of the fires are out and I'm getting some time to cycle back around and do things "right". I'll put this back on the list!

xpersonas’s picture

subscribe

leevh’s picture

subscribe

jrust’s picture

Status: Active » Fixed

Added in dev.

mattcasey’s picture

I have two issues with the dev:
1. when I select Filter by Terms, it incorrectly includes the full list from "Filter by Products" plus the Term list tacked on at the end.
2. when I save the discount, it reloads the form but no products are selected for either Required Products or Discounted Products. If I just hit "Submit" again, I get the error "At least one product must be selected." with both fields red.

jrust’s picture

Hmm, I don't have any ideas as it's working on my end. If you're able to debug further that would be helpful.

mattcasey’s picture

The fields are now being saved, I had to run update.php and there were a number of updates to the uc_discount.module, using UC 2.6. I still see the full list of products with the list of terms, but that's not as much of an issue. I will try to debug it more

mattcasey’s picture

It looks like $options needs to be reset when creating the list of terms in uc_discounts.admin.inc. This is how the other lists are set up. This fix works for me, starting at line 472:

  $name = "$grouping-filter-select-" . FILTER_TYPE_TERMS;
  $term_ids = isset($form_state['values'][$name]) ? $form_state['values'][$name] : get_term_ids_for_discount($discount_id, $grouping, FALSE);
  $options = array(); // New line
  if ($grouping == DISCOUNT_FILTER_GROUPING_APPLICATION) {
    $options = array(ALL_TERMS => t("<All Terms>"));
  }
  $options += taxonomy_form_all();
  $form[$fieldset_name]['filter'][$name] = array(
    "#type" => "select",
    "#title" => t("Terms"),
    "#description" => t("Select all terms this discount applies to or &lt;All Terms&gt; to apply to all terms.  Selections are <b>not</b> recursive."),
    "#options" => $options,
    "#default_value" => $term_ids,
    "#multiple" => TRUE,
  );
jrust’s picture

Sweet, pushed the fix.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.