Score:0

Single product with multiple variation types: set-up for a product (book) that's available as hardcopy and as downloadable file

mx flag

I'm searching for an approach for selling printed books as well as e-books in different file formats with Drupal Commerce:

  1. Hardcopy (variation type 1)
  2. PDF file (variation type 2)
  3. ePUB file (variation type 2)

While variation type 1 works fine as a regular product variation, variation type 2 is working with commerce_license and commerce_file: Product option 1 (hardcopy) will be shipped and will NOT include a file or license, options 2 and 3 will NOT be shipped, but will include a downloadable file and a license.

It would be great if I could use different variation types for the same product, then they can be used as different options for the same product, instead of splitting the different options into two different products (when they are the same product for 95% of the fields – same title, description, images, etc.).

To my knowledge, a single product with multiple variation types isn't possible with Drupal Commerce. This shortcoming is discussed in https://www.drupal.org/comment/reply/3089040, but unfortunately that thread is not easily understandable for me, deals with backward-compatibility and dates back to 2019.

So what's a good approach for selling printed and digital versions of books with Drupal Commerce in 2023 when starting with a clean Drupal 10? No need for backward compatibility, instead, the approach should focus on future-proofness and should be as little hacky as possible.

Score:1
cn flag

It would be great if I could use different variation types for the same product, then they can be used as different options for the same product, instead of splitting the different options into two different products (when they are the same product for 95% of the fields – same title, description, images, etc.).

Speaking as someone who has built a Commerce store that sells ebooks and print books, there are many cases in which you may want to treat physical and digital products separately.

For example, you may want to charge shipping for the print copy, but you would not charge shipping for a digital copy.

I would create two different products, physical and digital.

And if you want to offer them together at a discount, you could create a third product that contains both.

If you have a lot of information that you want to share between them-- for example, the book title, description, and so on are the same-- then create a custom content type (for "Books I sell") and input all the information there, and then add an entity reference to that content type on the product.

The trick with Drupal Commerce is to figure out what things should be shared and what things should be different, and then create new entities/bundles (content types, product types, etc.) until you have a sensible setup.

Madam Adam avatar
mx flag
Thank you for sharing your experience and knowledge. You wrote "If you have a lot of information that you want to share between them […]", so this would mean I create a custom content type "Book" which references the product types "Printed Book" and/or "E-Book" which on the other hand may refer to several product variation types ("Hardcover" and "Paperback" for Printed Books for example)?
cn flag
@MadamAdam The entity reference field to the **Book** content type should be added to the product type. This way, you can create one **Book** node with all the book info/images, etc, and then just use autocomplete in the entity reference field on each product to pull in all the book information. You can use Layout Builder or Views to get the **Book** node type information and add it to the product display.
Madam Adam avatar
mx flag
Thank you very much!
Madam Adam avatar
mx flag
Patrick, when experimenting with your suggestion, this question came up: why putting a reference field to the content type into the product instead of putting a reference field to the products into the book content type? What are the advantages? (Somehow I just don't get the bigger picture of why you are doing it the way you suggested.)
Madam Adam avatar
mx flag
I want to describe more precisely my concerns. For the backend user, your suggestion results in 3 different parts: Book Content Type, Book Producttype Print und Book Product Type Ebook. Backend users tell me that this spread of information is very confusing. So these considerations led to my subsequent questions as well.
cn flag
Yes, I suggest the three different parts you describe. They might be less confusing if you rename them: Book product details (book content type), printed book details (Book Product Type Print), and ebook details (Book Product Type Ebook). The reason I would set it up this way is to minimize data duplication. You could do just ebooks + printed books, but then you would have to copy and paste the book data instead of sharing it, which will probably result in data getting out of sync over time.
cn flag
Instead of putting the reference to the book content type in the products, you could do the reverse and put a reference to the products in the book content type. But if you are building an online bookstore of some sort like Amazon, it's probably easier to have the product be the primary unit instead of the book itself. If you are actually building something like Goodreads instead, you might want to do the reverse.
Madam Adam avatar
mx flag
I watched https://www.youtube.com/watch?v=3FXIV4bN-nc and installed commerce kickstart as shown in the video. Surprisingly, there's only one product type called 'media' which can reference the digital variation 'Media License Download' as well as the physical variation 'Media Physical' — so that would be exactly the set-up I was looking for … What do you think about that?
cn flag
@MadamAdam I'm sorry, I don't have time to watch an hour-long video, and that kind of discussion is out of scope for this site.
Madam Adam avatar
mx flag
Yes, sure. But on the bottom line since this commit https://www.drupal.org/project/commerce/issues/3089040#comment-14422573 it's not necessary to split into a digital and a physical product type anymore. Just use one product type and then reference physical and digital variations.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.