• Development

    Allowing Users to Cancel Their Own Commerce Licenses

    UPDATE: I’ve written a contrib module called Commerce License Cancel to get the ball rolling to make this a community effort. Read on if you’d like to see how I got there.

    There’s been some talk in the issue queue for Commerce License Billing about needing a way for users to cancel their own licenses. Here are some pieces and parts that I’m using to achieve this. This is a work in progress and I’m really just posting here so I can provide a clean link in the issue queue. Sorry for the lack of detailed explanations; hopefully you still find this helpful.

    There’s already a method to “revoke” a user license. When you revoke a license, the recurring billing should close out automatically and the role granted (if it’s a licensed role) will be taken away from the user.

    The site I’m working on has just a few “membership plans” or levels that a user can purchase. For this reason, I could hardcode a few things. It’d take a LOT more work to make this stuff ready for the masses.

  • Development

    Free Shipping for Specific Products in Drupal Commerce

    Recently I had a client call me asking if she could offer free shipping on a specific promotional/limited-run product. Unfortunately I didn’t find any clear-cut solutions in contrib or Drupal Commerce core. Also, I could not come up with a way to do this in core through the Drupal admin UI. It’s very easy to allow a “Free” shipping method if a specific product is found in the cart/order, but we only wanted the “free” deal to apply to the single product (any quantity of it).

  • Development

    Drupal 7 – Commerce Migration Class

    Here’s a migration class I’ve been working on to import 8200 products. The biggest feature of this code is that it will automatically create a single product display node that groups all products who share the same “grouping identifier.” So, in my CSV import file I have a “grouping_identifier” column. If a product is available in ten colors, and they all share the same grouping identifier, a single product display will be created and each of these products will be referenced in it. This will result in a product on the frontend that allows ten different color choices. I don’t have the time right now to explain anything more… please leave a comment if you have a question.

  • Development

    Drupal Commerce Add To Cart Form Tweaks / Registration Improvements

    In this example I’m showing how to improve the Add to Cart button for Drupal Commerce products to show differently based on whether or not users have already purchased a product, or whether the product is already in their cart.

    I’m currently working on a site where users are registering for “programs,” which are synonymous with classes, courses, etc. I’m using the following modules (among others) in this example:

    • Drupal Commerce
    • Registration
    • Commerce Registration

    Please understand that when a user registers for a course, they are actually purchasing a product that has a referenced Registration entity.

  • Development

    Creating a Link on a Product Display Node to Edit a Referenced Product

    Drupal Commerce is amazing. On a recent project I had the pleasure of working with it for the first time. I understood the link between products and product displays, but there were a few things that bothered me about the relationship. This example demonstrates a simple administrative UI modification to make it easier to edit a product display node’s referenced product. Notice I said product, not products. On this site, the requirement calls for a one-to-one relationship. Every product display will only have a single product. You’ll have to make modifications (to the block’s contextual filter (to support multiple arguments) and the PHP code (to pass back multiple product ids)) if you want to show multiple referenced products.