Importing Localist Events with Feeds

I’ve been fiddling around for a while with trying to figure out a good method for getting events out of our central events calendar. Colleagues and I had toyed with implementing modules to provide a block or custom Views code to feed JSON into a table or what have you. Recently I came across Baris Wanschers’ article about importing a twitter feed and realized it was exactly what we needed.

A grid of images and descriptions of upcoming events.

While I still think having some kind of Views module specific to this task would be useful, this works well as a simple solution leveraging existing modules.

Continue reading

Product Type Pricing Rules in Drupal Commerce

Recently, I wanted to do rule-based pricing in Drupal Commerce, but only for a certain product type. Commerce ships with a rule to react on “Calculating the Sell Price of a Product” and an associated set of actions to discount by a percentage (10% off!), fixed amount ($10 off!), or set a fixed price (only $10!).

This is what you’ll typically find documented, but I got tripped up trying to add a condition to only apply a discount to certain product types instead of globally discounting products (all square widgets only $10!). By default, though, I wasn’t able to use the line item’s product type in a data comparison condition.

Turns out you can do this, but, as is so often the case, you need to figure out what magical incantation will give you the rules scope you need. In this case, adding an “Entity has field” condition to check that the entity has the ‘commerce_product’ field does the trick. From there, you’ll be able to add another condition and reference the commerce-line-item:commerce-product: selector to do your comparison.

Update: I’ve posted a sample rule for those who would like to see a complete implementation.