0

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.

1 Answer 1

1

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.

10
  • 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)?
    – Madam Adam
    May 1 at 14:07
  • @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. May 2 at 7:54
  • Thank you very much!
    – Madam Adam
    Jul 11 at 16:10
  • 1
    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. Aug 13 at 3:19
  • 1
    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. Aug 13 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.