function uc_payment_method_check in Ubercart 5
Same name and namespace in other branches
- 6.2 payment/uc_payment_pack/uc_payment_pack.module \uc_payment_method_check()
- 7.3 payment/uc_payment_pack/uc_payment_pack.module \uc_payment_method_check()
Handle the Check payment method.
2 string references to 'uc_payment_method_check'
- hook_payment_method in docs/
hooks.php - Register callbacks for payment methods.
- uc_payment_pack_payment_method in payment/
uc_payment_pack/ uc_payment_pack.module - Implementation of hook_payment_method().
File
- payment/
uc_payment_pack/ uc_payment_pack.module, line 253 - Provides the check/money order, COD, and "other" payment methods.
Code
function uc_payment_method_check($op, &$arg1) {
switch ($op) {
case 'cart-details':
if (!variable_get('uc_check_mailing_street1', FALSE)) {
$details = t('Checks should be made out to:') . '<p>' . uc_address_format(variable_get('uc_store_name', ''), NULL, variable_get('uc_store_company', ''), variable_get('uc_store_street1', ''), variable_get('uc_store_street2', ''), variable_get('uc_store_city', ''), variable_get('uc_store_zone', ''), variable_get('uc_store_postal_code', ''), variable_get('uc_store_country', 840)) . '</p><p>' . variable_get('uc_check_policy', '') . '</p>';
}
else {
$details = t('Checks should be made out to:') . '<p>' . uc_address_format(variable_get('uc_check_mailing_name', ''), NULL, variable_get('uc_check_mailing_company', ''), variable_get('uc_check_mailing_street1', ''), variable_get('uc_check_mailing_street2', ''), variable_get('uc_check_mailing_city', ''), variable_get('uc_check_mailing_zone', ''), variable_get('uc_check_mailing_postal_code', ''), variable_get('uc_check_mailing_country', 840)) . '</p><p>' . variable_get('uc_check_policy', '') . '</p>';
}
return $details;
case 'cart-review':
if (!variable_get('uc_check_mailing_street1', FALSE)) {
$review[] = array(
'title' => t('Mail to'),
'data' => uc_address_format(variable_get('uc_store_name', ''), NULL, variable_get('uc_store_company', ''), variable_get('uc_store_street1', ''), variable_get('uc_store_street2', ''), variable_get('uc_store_city', ''), variable_get('uc_store_zone', ''), variable_get('uc_store_postal_code', ''), variable_get('uc_store_country', 840)),
);
}
else {
$review[] = array(
'title' => t('Mail to'),
'data' => uc_address_format(variable_get('uc_check_mailing_name', ''), NULL, variable_get('uc_check_mailing_company', ''), variable_get('uc_check_mailing_street1', ''), variable_get('uc_check_mailing_street2', ''), variable_get('uc_check_mailing_city', ''), variable_get('uc_check_mailing_zone', ''), variable_get('uc_check_mailing_postal_code', ''), variable_get('uc_check_mailing_country', 840)),
);
}
return $review;
case 'order-view':
if (!variable_get('uc_payment_tracking', TRUE)) {
return '';
}
$result = db_query("SELECT clear_date FROM {uc_payment_check} WHERE " . "order_id = %d ", $arg1->order_id);
if ($check = db_fetch_object($result)) {
$output = t('Clear Date:') . ' ' . format_date($check->clear_date, 'custom', variable_get('uc_date_format_default', 'm/d/Y'));
}
else {
$output = l(t('Receive Check'), 'admin/store/orders/' . $arg1->order_id . '/receive_check');
}
$output .= '<br />';
return $output;
case 'customer-view':
if (!variable_get('uc_payment_tracking', TRUE)) {
return '';
}
$result = db_query("SELECT clear_date FROM {uc_payment_check} WHERE " . "order_id = %d ", $arg1->order_id);
if ($check = db_fetch_object($result)) {
$output = t('Check received') . '<br />' . t('Expected clear date:') . '<br />' . format_date($check->clear_date, 'custom', variable_get('uc_date_format_default', 'm/d/Y'));
}
return $output;
case 'settings':
$form['check_address_info'] = array(
'#value' => '<div>' . t('Set the mailing address to display to customers who choose this payment method during checkout.') . '</div>',
);
$form['uc_check_mailing_company'] = uc_textfield(uc_get_field_name('company'), variable_get('uc_check_mailing_company', ''), FALSE, NULL, 128);
$form['uc_check_mailing_name'] = uc_textfield(t('Contact'), variable_get('uc_check_mailing_name', ''), FALSE, t('Direct checks to a person or department.'), 128);
$form['uc_check_mailing_street1'] = uc_textfield(uc_get_field_name('street1'), variable_get('uc_check_mailing_street1', ''), FALSE, NULL, 128);
$form['uc_check_mailing_street2'] = uc_textfield(uc_get_field_name('street2'), variable_get('uc_check_mailing_street2', ''), FALSE, NULL, 128);
$form['uc_check_mailing_city'] = uc_textfield(uc_get_field_name('city'), variable_get('uc_check_mailing_city', ''), FALSE);
$form['uc_check_mailing_country'] = uc_country_select(uc_get_field_name('country'), variable_get('uc_check_mailing_country', 840));
if (isset($_POST['uc_check_mailing_country'])) {
$country_id = intval($_POST['uc_check_mailing_country']);
}
else {
$country_id = variable_get('uc_check_mailing_country', 840);
}
$form['uc_check_mailing_zone'] = uc_zone_select(uc_get_field_name('zone'), variable_get('uc_check_mailing_zone', ''), FALSE, $country_id);
$form['uc_check_mailing_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), variable_get('uc_check_mailing_postal_code', ''), FALSE, NULL, 10, 10);
$form['uc_check_policy'] = array(
'#type' => 'textarea',
'#title' => t('Check payment policy'),
'#description' => t('Instructions for customers on the checkout page.'),
'#default_value' => variable_get('uc_check_policy', t('Personal and business checks will be held for up to 10 business days to ensure payment clears before an order is shipped.')),
'#rows' => 3,
);
return $form;
}
}