Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /home1/tylerfra/public_html/includes/common.inc).

commerce

The Drupal Commerce module.

Drupal Commerce Order Owner Autocomplete with E-mail Address

When creating an order as an admin in Drupal Commerce, we can specify the user that owns the order if we know their user name. This works well in most cases, but to be able to search by the user's e-mail address would be helpful too. I've had a few requests from clients for this feature. So without further ado, let's ado it!

/**
 * Implements hook_menu().
 */
function my_module_menu() {
  $items = array();
  $items['my_module/commerce/order-owner/autocomplete'] = array(
    'page callback' => 'my_module_commerce_order_owner_autocomplete',
    'access arguments' => array('configure order settings'),
    'type' => MENU_CALLBACK
  );
  return $items;
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function my_module_form_commerce_order_ui_order_form_alter(&$form, &$form_state, $form_id) {
  // Attach our custom autocomplete to the order owner name input so we can
  // search by e-mail address.
  $form['user']['name']['#autocomplete_path'] = 'my_module/commerce/order-owner/autocomplete';
}

/**
 * Queries results for the commerce order owner autocomplete.
 */
function my_module_commerce_order_owner_autocomplete($string) {
  $matches = array();
  $query = db_select('users', 'u');
  $query
    ->fields('u', array('uid', 'name', 'mail'))
    ->condition(db_or()
      ->condition("u.mail", '%' . db_like($string) . '%', 'LIKE')
      ->condition("u.name", '%' . db_like($string) . '%', 'LIKE')
    )
    ->condition('u.uid', 0, '<>')
    ->range(0, 10);
  $results = $query->execute();
  foreach ($results as $row) {
    $key = "$row->name";
    $matches[$key] = "$row->name - $row->mail ($row->uid)";
  }
  drupal_json_output($matches);
}

EntityMetadataWrapperException: Unknown data property commerce_product. in EntityStructureWrapper->getPropertyInfo()

After struggling with this issue for days, and days, and days, and more days, I was finally able to debug it by placing the following line of code in the getPropertyInfo() function inside of the sites/all/modules/entity/includes/entity.wrapper.inc file (be sure to have the Devel module enabled on your Drupal site):

dpm(debug_backtrace());

The code above should go right before this line:

Build a Mobile App to Sell Products with Drupal

This tutorial describes how to create a website and mobile application to sell physical products. Customers on a desktop or laptop computer will be able to purchase the product through the website, much like a typical e-commerce store.

Once we have built the mobile application, customers who have downloaded and installed the mobile app onto their Android or iOS (iPhone, iPad) device will be able to purchase the product as an In-App Purchase.

For this example website and mobile app, we're going to sell bottles of beer. *Cough* - Please don't actually sell beer without first getting permission from your local Big Brother.

The main 3 sets of tools we will utilize are:

This tutorial was inspired by this Session from DrupalCon Austin 2014. If you're new to any of these tools mentioned above, please watch the video for an introduction. Otherwise, let's get started!

Drupal - Address Field Phone, How to Make it Required

I've been using the Address Field Phone module with the Commerce and Address Field modules to collect a phone number from users during the checkout process.

Drupal - Commerce Price Range Navigation

While building a Drupal 7 Commerce site, I needed a price range navigation block so customers could search for products within a specific set of price ranges.

Here's an example website (buy some sexy clothes for your girlfriend/wife/self while you're there) showing off this feature.

Here's an example screen shot:

Subscribe to RSS - commerce