0

I have a shop using Expresso Store where we have add to cart buttons in the site search results but as some products have modifiers we are seeing an error as follows when trying to use these:

Modifier error

I would like these add to cart buttons on results pages to default to the highest value modifier. Is that possible?

To clarify, I do not want to show the modifier options on the results pages, these will appear only on the actual product detail pages.

1

There is not really a built in way to preselect the most expensive modifier by default.

Having said that, then you should be able to get around that as long as you setup some publishing standards. The easiest way should be to make sure that either the first or last modifier is the most expensive.

If you have done that you should simply need to add the modifier as a hidden field. It would look something along the lines of the following:

{exp:store:product entry_id="{entry_id}"}

  <h2>{title}</h2>
  {if modifiers}
      {modifiers}
        Price: {price_inc_mod}

        {modifier_options}
          {if option_last}
          {!-- this could also be if option_first if you decided to make the first option most expesnsive --}
            <input type="hidden" name="{modifier_input_name}" value="{option_id}">
          {/if}
        {/modifier_options}
      {/modifiers}
  {else}
    {!-- if no modifiers show regualr price --}
    Price: {price}
  {/if}
  <input type="text" name="item_qty" value="" />
  <input type="submit" name="submit" value="Add to Cart" />
{/exp:store:product}

This assumes that you are passing in the entry id and that each product has its own form and quantity. IF you were wanting all the results to have a single form submit with the ability to add multiple items to the cart at a single time you would need to wrap this in the Product Form tag pair and adjust the template at bit.

  • Thanks, this works a treat! Out of interest what's the performance impact though... i.e. on a page with 20 product results is this going to significantly increase page load times? – Nathan Pitman Jan 28 '15 at 11:43
  • It shouldn't add add any additional processing then having 20 add to cart forms without the modifiers tag pair. – Justin Long Jan 28 '15 at 19:28
  • Having said that I haven't done any performance test in a situation like this to back up my previous comment. – Justin Long Jan 28 '15 at 19:30

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.