Drupal Commerce

Drupal 7: Addressfield - Change the order of the inner fields

A request that often comes up is to change the order of the Addressfield fields.
In this example, we are creating a custom module in order to position the Country field at the bottom.
It is a very simple function, and the other elements can be positioned in a similar fashion.

Drupal Commerce - Translate Order total, Shipping Information, Billing information

If you do not want to use i18n_string and i18n_field in order to translate the Order total, Shipping & Billing Information texts, that show up in the cart and on the checkout pages when using Drupal Commerce, the following hacky approach should do the trick.

First, the following funcion can be used in your template.php file:

Drupal Commerce - "Select a product" element: How to change the select list to radio buttons

Here is the code that changes the default select list of "Select a product" element of Drupal Commerce to radio buttons, for a standalone product list.

The following goes in a custom module (tested in Drupal 7).

<?php
function MYMODULE_form_alter(&$form, $form_state, $form_id) {
  if (
strpos($form_id, 'commerce_cart_add_to_cart_form_') === 0 && isset($form['product_id'])) {
   
$form['product_id']['#type'] = "radios";   
  }
}
?>

Recent Comments

Forward by Dries Buytaert, Founder and Project Lead, Drupal; CTO Acquia.

Order now from:

Managing Expectations Podcast with DrupalEasy

Author Interview http://tinyurl.com/8a8nxno

We provide the most Shiny Drupal Bits & Pixels

Since Drupal 4.x

© 2014 Konordo Limited
Drupal Services provider.
All rights reserved.

Reg Nr. 12301661F
VAT Nr. CY10301661D

M. Director: Konstantin Ordoulidis

 

Get in touch

  • Omirou 10, 3095, Limassol, Cyprus
  • +4917698807355
  • info [at] konordo [dot] com

Submit
randomness