Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By macman on
Hi
I have been cracking my head open trying to modify the customer information pane in the Ubercart checkout (cart/checkout page).
I have tried a module using hook_checkout_pane_alter as follows:
// $Id$
/**
* @file
* Modifies the customer info description in the checkout
*/
/**
* Implementation of hook_checkout_pane_alter()
*/
function uc_alter_custinfo_checkout_pane_alter(&$panes){
foreach ($panes as &$pane) {
if ($pane['id'] == 'customer') {
$pane['#description']= 'Additional Information';
}
}
}
I have also tried using hook_form_alter as follows:
// $Id$
/**
* @file
* Modifies the customer info description in the checkout
*/
/**
* Implementation of hook_form_alter()
*/
function uc_alter_custinfo_form_alter($form_id, &$form){
if ($form_id == 'uc_cart_checkout_form'){
$form['panes']['customer']['#description']= 'My changed text';
};
}
In the end I hacked /ubercart/uc_cart/uc_cart_checkout_pane.inc to make the changes. I know that this is completely the wrong way to do it. If someone can please help me to get it done properly, I would really appreciate it.
Thanks
Chris
Comments
Subscribing, needing changes
Subscribing, needing changes also in the checkout page of Ubercart.
I saw posts about doing a form alter. But do not know enough about it.
Greetings, Martijn
Hi macman, did you find a
Hi macman,
did you find a solution to this that does not require hacking ubercart/uc_cart/uc_cart_checkout_pane.inc?
I am researching the same issue.
Thanks, Tom
I'm able to successfully
I'm able to successfully alter pane info using hook_form_alter. In the examples above, you are calling hook_form_alter() without any arguments. You should have $form, $form_state, and $form_id. Here is my example:
In the example above I've changed the title of the Cart pane and changed the "#action" parameter of the entire checkout form. This is useful for instance with a 3rd-party payment gateway that requires the credit card info be submitted to them, and not to Drupal. I'm currently using this method to submit customer billing info to Braintree's Transparent Redirect payment gateway (getbraintree.com).
Have I helped you? Consider buying me a beer.
This is what helped me, thank
This is what helped me, thank you
Adding a new pane to checkout Ubercart
Adding a new checkout pane is very easy in drupal 7:--
write this function with new pane name. Here is my new pane id "taxpane" .
function uc_checkout_pane_taxpane($op, $order, $form = NULL, &$form_state = NULL) {
global $user;
switch ($op) {
case 'view':
global $user;
if ($user->uid) {
$is_tax_exempted = db_query("SELECT field_taxexempt_value FROM {field_data_field_taxexempt}
where entity_id= :uid", array(':uid' =>$user->uid))->fetchField();
$tax_id = '';
if( isset($is_tax_exempted) ) {
$tax_id = db_query("SELECT field_taxid_value FROM {field_data_field_taxid}
where entity_id= :uid", array(':uid' =>$user->uid))->fetchField();
$description = t('Your tax id below.');// . '
'
//$contents['primary_email'] = array('#type' => 'hidden', '#value' => check_plain($email));
$contents['email_text'] = array(
'#markup' => '
',
);
return array('description' => $description, 'contents' => $contents);
}
else {
return array('description' => '', 'contents' => '');
}
}
return array('description' => '', 'contents' => '');
case 'process':
$pane = $form_state['values']['panes']['taxpane'];
if (!empty($pane['email_text']) ) {
$order->taxid = $pane['email_text']; }
return TRUE;
}
}
The above will add a new pane @ ubercart checkout.
Similarly, for review checkout pane you can put
case 'review':
global $user;
if ($user->uid) {
//// my local code . Write your own instead of it .
$is_tax_exempted = db_query("SELECT field_taxexempt_value FROM {field_data_field_taxexempt}
where entity_id= :uid", array(':uid' =>$user->uid))->fetchField();
$tax_id = '';
if( isset($is_tax_exempted) ) {
$tax_id = db_query("SELECT field_taxid_value FROM {field_data_field_taxid}
where entity_id= :uid", array(':uid' =>$user->uid))->fetchField();
}
}
$review[] = array('title' => t('Tax ID'), 'data' => $tax_id ); //check_plain($order->email_text));
return $review;
Vikas kumar