Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payment Methods change per customer


gazzzzzza

Recommended Posts

I have set up oscommerce and have severly modified it and am getting to the final stages.

 

The client sets up their own customers through an admin area that I have created. This is due to them having to enter many extra bits of information to help the modifications I have made to the site work. They can select which payment methods they want each customer to be allowed to use. This is at the request of their customers who do not want a mutltitude of payment options.

 

So as it stands, I have settings in the database for each customer which are set as 0 or 1 for each payment method. What I want to do is set up checkout_payment.php so when it creates the radio buttons it checks each setting and if it = 1 then it displays the method otherwise it does not.

 

The code that needs modifying is below but I cannot figure out where to put in the if statements for each payment method as it seems to use an array full of the payment methods.

 

----- START CODE

 

<?php

if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {

echo '<tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

} else {

echo '<tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

}

?>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main" colspan="3"><b><?php echo $selection[$i]['module']; ?></b></td>

<td class="main" align="right">

<?php

if (sizeof($selection) > 1) {

echo tep_draw_radio_field('payment', $selection[$i]['id']);

} else {

echo tep_draw_hidden_field('payment', $selection[$i]['id']);

}

?>

</td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td></tr>

<?php

if (isset($selection[$i]['error'])) {

?>

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main" colspan="4"><?php echo $selection[$i]['error']; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

} elseif (isset($selection[$i]['fields']) && is_array($selection[$i]['fields'])) {

?>

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td colspan="4"><table border="0" cellspacing="0" cellpadding="2">

<?php

for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {

?>

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main"><?php echo $selection[$i]['fields'][$j]['title']; ?></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<td class="main"><?php echo $selection[$i]['fields'][$j]['field']; ?></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

}

?>

</table></td>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

}

?>

</table></td>

<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

</tr>

<?php

$radio_buttons++;

}

?>

 

----- END CODE

 

 

 

I would be grateful for any assistance :D

always here to offer some useless advice....

Link to comment
Share on other sites

I managed to get it working

 

For anyone who is interested here is how

 

on checkout payment, i ran a query to the database to find out which methods the customer was allowed to use. set the answers in 3 global vars-1 for each payment method installed.

 

then on each payment method module i add ed the code below.

 

 

--------- START CODE (eg is credit card module)

 

// class methods

function update_status() {

global $order;

global $allow_cc; // VARIABLE THAT SAYS IF CC PAYMENT IS ALLOWED

 

 

// ADDED THIS CODE

 

if($allow_cc == 1) {

$this->enabled = true;

} else {

$this->enabled = false;

}

 

// END ADDED CODE

 

----------END CODE

 

This bit of code sets the 'module enabled' variable dependent on whther the global is set to 0 or 1. If it is 0 then the module is not loaded for use in the payment selection section.

 

Please note that more code is needed to modifythe following page because errors occur when only one method is allowed. The choice of payment module does not get auto selected so needs to be manually inputted in the code using a query which finds if only one method selected-then it chooses that method. if anyone needs help with this let me know.

always here to offer some useless advice....

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...