Planet Drupal

Commerce Module Tuesday: Commerce Price Table

Commerce Price table is a module that provides both a field type and a display formatter that allows to manage and displays prices in a table based in the quantity so that different prices can be shown depending on the quantity of products that the customer purchases.

It plays nice with the default price field, allowing to hide it in the edit forms and replacing it in a transparent way using the power of rules and all the pricing rules that you apply to prices are also applied to the price table, such as taxes, discounts, etc.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Custom Email Notifications in Drupal Commerce (screencast)

This screencast demonstrates how to do custom per-product email notifications. After adding a multivalued "notification" field to the product, we can check through the order on order completion to see if there are products which have product owners who need to be notified. The logic is "When the checkout process is completed", Loop through the line items in the order. For each line item, call a component (a Rules subroutine) that checks to see if the line item is associated with a product, and if so, if it has notification fields filled out. If so, the action is to loop through the emails in the multivalued notification field and send a tokenized email to each one.

Before getting started I mention the three things that persistently give people trouble with Commerce and Rules, and some solutions:

  1. Not understanding rules in the first place: Spend a few hours starting from the beginning with Itangalo's outstanding "Learn the Rules Framework" video series.
  2. Not understanding how to bring related fields and entities into scope: Read the FAQ about bringing fields into scope from the Drupal Commerce FAQ.
  3. Not understanding how to use conditions in a loop or how to use Rules Components (subroutines), which is something we'll demonstrate here.

Here's the screencast:

rfay's picture
Randy Fay

Randy has been doing software development since 1981 and web development since 1994, having built systems in a myriad of languages and environments. He stumbled into the Drupal community by moving a number of dynamic websites to Drupal in the 4.6 days (2004?) and became an active Drupal core developer after an epic bicycle ride from Canada to Argentina in 2006-2008. He is an active Drupal core contributor, is a co-maintainer of the Drupal AJAX subsystem, and developed and maintains a number of contrib modules on Drupal.org. His blog is at randyfay.com.

Commerce Module Tuesday: Commerce Price Savings Formatter

Commerce Price Savings Formatter achieves a very demanded and useful feature for managing Drupal Commerce prices, it displays the original price of the products crossed and enhances the discounted price, displaying the amount and percentage that the customer would save if they purchase the item. All those components are optional so you can choose which to show in your prices.

The module uses a display formatter for doing all these operations so it can be used both in the display fields configuration screen and in Views. Oh, and it is also VAT safe, which is a great thing.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Commerce Module Tuesday: Manual payment methods for Drupal Commerce

There are many automated payment methods for Drupal Commerce around, we have solutions for Paypal, Authorize.net, Ogone and of course a lot of local banks, but there are some that are also widely used and are somehow "manual", we're going to take a look to three of them:

  • Commerce Bank Transfer allows to input bank information that is going to be displayed to the user so they can note that down and make a wire transfer for the total of the purchase.
  • Commerce Cheque and Commerce Cash on Delivery are quite similar, both of them need some information filled in their settings that is going to be exposed to the user so they can follow the payment instructions, however the intention of the modules is quite different as one is for cheque payments and the other to pay when the items purchased are sucessfully delivered.

The three of them need some manual action from the store administrator to actually confirm that the payment has been done.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Commerce Module Tuesday: Commerce Views Bulk Operations

Commerce Views Bulk Operations replaces Drupal Commerce default administrative Views for managing Orders, Products, Product Displays, Customer Profiles, etc and allows to perform massive operations on all those items, easing administrative tasks.

When you enable this module, some of the default views that are disabled, those will be enabled again when disabling Commerce VBO.

Thanks to the Rules integration with Views Bulk Operations, you can also configure new custom Rules actions and expose them to Views.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Commerce Module Tuesday: Commerce Bulk Product Creation

Commerce Bulk Product Creation was the first contributed module to the commerce project and provides a quick way to create multiple combinations of products with a single form submission. It also optionally manages the creation of the display associated to the product variations in different ways such as generating a display for each product created in bulk.

Some conditions in the product configuration need to be met in order to use the bulk creation feature, you need to have one or more fields of list type, boolean or term references with the submodule for taxonomy support. There's also support for Entity Reference fields with the BPC entity reference module.

Note that once created, this module doesn't support yet bulk edition or deleting, you may find useful Commerce VBO for that purpose, but that belongs to other Tuesday's overview.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Commerce Module Tuesday: Commerce Stock

Commerce Stock is a great demonstration of how Drupal Commerce can be extended with great Drupal 7 features. It adds an integer field for "stock" to a product, and then manages that using rules.

To use Commerce Stock, just enable the module and then visit admin/commerce/config/stock to configure which product types it should be configured for. At this point, a stock field will be added to your products and you can set the initial stock value.

Now, whenever a product is checked out, the stock level will be decremented, and if it reaches zero, the add-to-cart button will be disabled.

Some details:

  • You can change when stock is decremented by using your own rule instead of the default rule. The default rule decrements stock "when completing the checkout process" but you might want to do it when an order is complete or when it is shipped.
  • Commerce Stock currently does not currently attempt to deal with purchase collisions (two customers purchasing the same product at the same time).
  • Version 7.x-1.x is not transactional, and does not have a log of when or why the stock was changed, but 7.x-2.x promises new capabilities (see the project page).
  • You can easily add the stock field to any view of products you use to see current stock levels.

Here's the screencast:

rfay's picture
Randy Fay

Randy has been doing software development since 1981 and web development since 1994, having built systems in a myriad of languages and environments. He stumbled into the Drupal community by moving a number of dynamic websites to Drupal in the 4.6 days (2004?) and became an active Drupal core developer after an epic bicycle ride from Canada to Argentina in 2006-2008. He is an active Drupal core contributor, is a co-maintainer of the Drupal AJAX subsystem, and developed and maintains a number of contrib modules on Drupal.org. His blog is at randyfay.com.

Commerce module tuesday: Commerce Fieldgroup Panes (Screencast)

Commerce Fieldgroup Panes is an excellent module that exposes fields into the checkout process. It creates one checkout pane for each fieldgroup of the order entity using Field group module.

This is one of the easiest ways to collect information in the checkout phase, it can be used for many purposes, probably getting customer comments is the most usual, but this screencast also shows how to use information exposed by this module as data for registering users in the checkout process.

These are the basic steps to set up this module and collect information from your customers.

  • Create one or several fields in the Order entity type (Store » Configuration » Order settings » Manage Fields)
  • Embed those fields justs created in a new Field group.
  • Access the checkout settings admin screen (Store » Configuration » Checkout settings)
  • Drag & drop your fieldgroups exposed as Checkout panes to the correct Checkout pages.

Other great thing of this simple and useful module is that all the information stored in the Order entity can be used afterwards with Rules and Views, the screencast below will also show how to use this collected information for creating new user accounts.

Pedro's picture
Pedro Cambra

Pedro Cambra is a Drupal developer and trainer based in Barcelona, Spain, with more than four years of experience in Drupal and PHP development mostly focused on building and maintaining e-commerce sites. Currently in lead of the Spanish Drupal association, Pedro helps organizing both Drupalcamps and local events and encourages local communities.

Selling Per-Node Access With Drupal Commerce

This screencast builds on the previous screencast showing selling a role. This time, though, we're going to sell an individual node. Here's the recipe:

  • We have Content Access and its submodule Content Access Rules enabled
  • Create a content type called Premium Content
  • Instead of granting access to that entire content type by role, grant it on a user-by-user, node-by-node basis
  • Add a nodereference field to our product; each product that sells access to a node should have the nodereference set to the content in question.
  • Add a rule (and component)
    • When the order is updated
    • If its state is Completed
    • Loop through the line items (invoke a component)
    • If the line item has a product reference field
    • If the Product has a nodereference field
    • Grant access to the node listed in the nodereference to the user who created the order.

rfay's picture
Randy Fay

Randy has been doing software development since 1981 and web development since 1994, having built systems in a myriad of languages and environments. He stumbled into the Drupal community by moving a number of dynamic websites to Drupal in the 4.6 days (2004?) and became an active Drupal core developer after an epic bicycle ride from Canada to Argentina in 2006-2008. He is an active Drupal core contributor, is a co-maintainer of the Drupal AJAX subsystem, and developed and maintains a number of contrib modules on Drupal.org. His blog is at randyfay.com.

Selling Content with Drupal Commerce using Content Access and Roles

In this screencast we'll use Drupal's built-in access control mechanisms (using the Content Access module) to grant access to premium content to users who have a "premium" role.

Here's the recipe:

  • Enable Content Access and the ACL (optional) module.
  • Create a role called "premium"
  • Create a content type called "Premium Content" and put some great content in it.
  • Verify that users can only access the premium content if they have the premium role.
  • Create a product representing the premium role.
  • Create a rule that grants the premium role on order completion:
    • After updating an order
    • If the order state is Completed
    • And the order contains our premium product
    • Add a role to the user who is the owner of the order

That's really all there is to it.

rfay's picture
Randy Fay

Randy has been doing software development since 1981 and web development since 1994, having built systems in a myriad of languages and environments. He stumbled into the Drupal community by moving a number of dynamic websites to Drupal in the 4.6 days (2004?) and became an active Drupal core developer after an epic bicycle ride from Canada to Argentina in 2006-2008. He is an active Drupal core contributor, is a co-maintainer of the Drupal AJAX subsystem, and developed and maintains a number of contrib modules on Drupal.org. His blog is at randyfay.com.

Syndicate content