Discussions

Editing content on the 'Checkout pane'

I've been trying to find a way to insert wording that is specific to various stages in the checkout process but haven't yet found a way of being able to do this.

Example (referenced in attached screenshot):

On the 'Shipping' checkout stage I would like to add some text underneath the "Shipping" H1 tag stating "Order before 4pm Monday to Friday for same day dispatch by first class post. Orders placed at weekends will be dispatched on Monday mornings."

The only way I've been able to get this content into the Shipping stage is by entering the wording into each individual shipping service's "Description" input box (Eg: admin/commerce/config/shipping/services/flat-rate-1st-class-mail/edit). This doesn't seem like the most elegant solution to me though.

Does anyone know if there is a way that I can enter the content on the page using another method? Is there something similar to what you're able to do with headers and footers whilst editing a view?

I'd also like to remove the default wording "Shipping service" (as seen in attached image)

I keep thinking I must be missing something really obvious here, sorry if I've overlooked this.

Thanks,
Kevin

AttachmentSize
Image icon shipping-content.jpg224.21 KB
Posted: Aug 28, 2014

Comments

joshmiller Josh Miller on August 28, 2014

The checkout form, even the multiple page one that comes with Kickstart 2, is just a Drupal form :)

Steps:

Step 1: Install the Devel module

Step 2: Find a place to do a hook_form_alter()

Often, for me, I like to make a site-specific custom module OR use template.php from my custom theme, depending on the level of effort involved.

Step 3: Write the hook_form_alter, add some debug statements

<?php
function THEMENAME_form_alter(&$form, &$form_state, $form_id) {
 
dpm($form_id);
 
dpm($form);
}
?>

That little bit of code dropped into your template.php would let you see (with the help of the devel module) the complex and yet simple array that is your form. You can change any of the $form['element']['#title']'s ... which would include your shipping service bit ... or you could replace it with a ['#markup'] and include a bit more html structure.

Step 4: Fix up hook_form_alter() by removing debug statements and fixing up the form.

Hope that helps!

Kevin Goodwin on September 1, 2014

Hi Josh,

Thank you for your response. Your example has been really useful!

Much appreciated.