address_checkoutapi(&$txn, $op, $post_op = NULL, $arg4 = NULL)
ecommerce-5--3/address/address.module, line 90
Implementation of hook_checkoutapi().
<?php
function address_checkoutapi(&$txn, $op, $post_op = NULL, $arg4 = NULL) {
global $user;
if ($txn == 'address') return TRUE;
$output = '';
switch ($op) {
case 'form':
if ($txn->shippable) {
drupal_set_title(t('Choose a shipping and billing address'));
}
else {
drupal_set_title(t('Choose a billing address'));
}
$form = address_checkout_form($txn);
$form[] = array('#type' => 'submit', '#default_value' => t('Continue'));
return $form;
case 'validate' :
if ($txn->uid > 0) {
if ($txn->shippable && !$txn->shipping_address) {
form_set_error('shipping_address', t('You need to select a shipping address.'));
}
if (!$txn->billing_address) {
form_set_error('billing_address', t('You need to select a billing address.'));
}
}
break;
case 'save':
if ($txn->uid > 0) {
$txn->address['shipping'] = address_get_address($txn->shipping_address ? $txn->shipping_address : $txn->billing_address);
$txn->address['billing'] = address_get_address($txn->billing_address);
}
else {
$txn->address['billing'] = (object)$txn->address['billing'];
if ($txn->address['shipping']) {
$txn->address['shipping'] = (object)$txn->address['shipping'];
}
}
$txn->screen++;
break;
case 'review':
if ($txn->shippable) {
$form['title'] = array( '#value' => t('Shipping and billing address') );
$form['shipping_address'] = array( '#value' => store_format_address($txn,'shipping','html') );
}
else {
$form['title'] = array( '#value' => t('Billing address') );
}
$form['billing_address'] = array( '#value' => store_format_address($txn,'billing','html') );
return $form;
}
}
?>