WooCommerce: Product variations that don’t require all options selected

So I thought I could figure this out in a fairly straightforward manner, but it has been utterly perplexing me: I’m setting up a store to sell fonts. These fonts are available in a variety of licenses that affect the price: For example:

  • Desktop
    • 1-5 Users
    • 6-10 Users
    • 10+ Users
  • Web
    • 1 Domain
    • Up to 5 Domains
    • Up to 10 Domains

…etc. As the store is selling packs & collections as well as individual weights & styles, all of these variations are customisable with regards to their price, attached files, etc. Plus, due to the licensing of some typefaces, not all are available under the same licenses.

Read More

The issue: If a user selects Desktop: 1-5 Users, then they definitely shouldn’t be required to select a Web license. However, if I try to add a font to my cart with just Desktop: 1-5 Users selected and no Web selection, it fails.

In the backend I currently have all Desktop variations set to ‘Any Web…’ and vice versa, but it doesn’t make any difference.

As an addendum to this, I experimented with using jQuery to set any unchosen selection’s value to ‘null’; so, user selects Desktop: 1-5 Users; Web dropdown is automatically hidden and value set to ‘null’. This works (sort of) insofar as the product will get added to the cart, but it appears as:

Fontname

  • Desktop: 1-5 Users
  • Web: null

Again, I can edit the template in /woocommerce/single-product/add-to-cart/variable.php to not display the null attribute on the site, but it still appears in emails, in the order on the backend, etc. Ideally I want a way to simply not have all license attributes being selected as a prerequisite of adding a font to the cart.

Hopefully I am just not seeing the wood for the trees here and missing something blindingly obvious and simple.

Related posts

Leave a Reply

2 comments

  1. It might be better to split the licenses into two separate products – web and desktop.

    Or perhaps you could chain or combine them using one of the Woothemes product grouping extensions. Alternatively, the Extra Product Options extension could be suitable to your needs. The Extra product options adds additional metadata to each order, you can use conditional logic on the product page to help guide a user to the best product/price match.

    Good luck! eCommerce is harder than it looks!

  2. Think about adding as default:

    • no web licence
    • no dekstop licence

    It will produce:

    Desktop

    • No desktop
    • 1-5 Users
    • 6-10 Users
    • 10+ Users

    Web

    • No web
    • 1 Domain
    • Up to 5 Domains
    • Up to 10 Domains

    In woocommerce you can select no web/desktop as default variation and uncheck visible on product page.

    Similar future can be achived by PHP code by hooking to woocommerce filters, but in my opinion using product configuration is much more elegant.