9 replies [Last post]
PaulW's picture
Offline
Joined: 05/23/2008
Juice: 148
Was this information Helpful?

Maybe this feature is already in Ubercart, but I couldn't find it.

I'd like to have a place to set a default number of days (ie "+10") that would set the "Expected clear date" when posting a check. Currently it defaults to the current date.

If this feature exists and I just couldn't find it, please point me in the right direction.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Expected Clear Date (Check) Default

I don't think the feature already exists... one difficult thing to track is what is a business day and what isn't... but I'm sure this could be worked with. I'll log it as a feature request... feel free to post a patch if you come up with one.

PaulW's picture
Offline
Joined: 05/23/2008
Juice: 148
Re: Re: Expected Clear Date (Check) Default

I was thinking more along the lines of number of calendar days to be consistent with statement on the checkout page: "Personal and business checks will be held for up to 10 business days to ensure payment clears before an order is complete."

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Expected Clear Date (Check) Default

The wording there says business days, which at least for us excludes weekends. Not sure what you mean... Puzzled

PaulW's picture
Offline
Joined: 05/23/2008
Juice: 148
Re: Re: Re: Re: Expected Clear Date (Check) Default

I guess it just seems like I work every day.

Ten "business days" could be interpreted as two calendar weeks. What I meant was (and it's no big deal) to have a default that one could set that would more typify the time needed to clear a check in their location. It would only save a couple of mouse clicks when posting a check - as I said, "no big deal".

biocomp.pat's picture
Offline
Joined: 01/05/2009
Juice: 61
Any headway on this?

Anyway, I just use this as an approximation, and I don't need anything fancy for business day, so I stole the code from uc_payment_pack.admin.inc and did this up. Just create a module or tack this on to one you use for tweaks, and change $clear_days to whatever you want.

<?php
/**
* Implementation of hook_form_alter().
*
* Changes default expected clear date for cheque in Uberbart
*/
function registration_form_alter(&$form, $form_state, $form_id) {
  if (
$form_id == 'receive_check') {
     
$clear_days = 14;
     
$clear_time = time() + $clear_days * 86400;
 
      unset(
$form['clear']['clear_month']);
      unset(
$form['clear']['clear_day']);
      unset(
$form['clear']['clear_year']);
     
$form['clear']['clear_month'] = uc_select_month(NULL, format_date($clear_time, 'custom', 'n'));
     
$form['clear']['clear_day'] = uc_select_day(NULL, format_date($clear_time, 'custom', 'j'));
     
$form['clear']['clear_year'] = uc_select_year(NULL, format_date($clear_time, 'custom', 'Y'), format_date($clear_time, 'custom', 'Y'), format_date($clear_time, 'custom', 'Y') + 1);
      foreach (array(
'clear_month', 'clear_day', 'clear_year') as $key) {
       
$form['clear'][$key]['#prefix'] = '<div style="float: left; margin-right: 1em;">';
       
$form['clear'][$key]['#suffix'] = '</div>';
      }
  }
}
?>

On a related note, I couldn't get this to work with hook_form_FORM_ID_alter... anyone have any clue why? I know that hook runs before hook_form_alter, but I wouldn't have thought that would change anything in this case...

Cheers all!

EDIT: Scratch that, the date field was showing up on every form because I had "if ($form_id = 'receive_check')", but when I change it to " if ($form_id == 'receive_check')", it stops working even in the place I want it to. Any thoughts?

biocomp.pat's picture
Offline
Joined: 01/05/2009
Juice: 61
Got it working

Blarg... I'm a dork. Didn't realize the form ID (uc_payment_pack_receive_check_form) was so big.

<?php
/**
* Implementation of hook_form_FORM_ID_alter().
*
* Changes default expected clear date for cheque in Uberbart
*/
function registration_form_uc_payment_pack_receive_check_form_alter(&$form, $form_state) {
 
$clear_days = 14;
 
$clear_time = time() + $clear_days * 86400;

  unset(

$form['clear']['clear_month']);
  unset(
$form['clear']['clear_day']);
  unset(
$form['clear']['clear_year']);
 
$form['clear']['clear_month'] = uc_select_month(NULL, format_date($clear_time, 'custom', 'n'));
 
$form['clear']['clear_day'] = uc_select_day(NULL, format_date($clear_time, 'custom', 'j'));
 
$form['clear']['clear_year'] = uc_select_year(NULL, format_date($clear_time, 'custom', 'Y'), format_date($clear_time, 'custom', 'Y'), format_date($clear_time, 'custom', 'Y') + 1);
  foreach (array(
'clear_month', 'clear_day', 'clear_year') as $key) {
   
$form['clear'][$key]['#prefix'] = '<div style="float: left; margin-right: 1em;">';
   
$form['clear'][$key]['#suffix'] = '</div>';
  }
}
?>
biocomp.pat's picture
Offline
Joined: 01/05/2009
Juice: 61
Small suggestion for Ryan

Oh hey, while I'm here, if you happen to read this Ryan, the wording for the checkbox on this page is slightly misleading. If I understand correctly "Check has already been received" should be "Check has already been cleared" (since it sets the clear date to today). I would think most people would be holding the check in their hands as they're filling out the "Check received" form, and that they'd be slightly confused (if only momentarily) as to why that checkbox is even there Smiling

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
biocomp.pat wrote:If you
biocomp.pat wrote:

If you happen to read this Ryan, the wording for the checkbox on this page is slightly misleading. If I understand correctly "Check has already been received" should be "Check has already been cleared" (since it sets the clear date to today).

Good call. Just updated that text. Smiling

fcadieux's picture
Offline
Joined: 02/27/2011
Juice: 3
Re: biocomp.pat wrote:If you

"Check has already been received" is associated with check_exists, which I think means that the payment was already entered (and most probably the balance is at 0)

$form['check_exists'] = array(
'#type' => 'checkbox',
'#title' => t('Check has already cleared.'),
'#attributes' => array('onclick' => 'receive_check_toggle(this.checked);'),
);

Therefore, I would recommend to revert back this change and move it back to "Check has already been received"

But I like the adjustment you made above for the default validation date.