Hi Everyone,
I am new to Zencart and enjoy the colloborative sharing that goes into this product.
In that spirit, I have created a slight modification to Philips great addon to allow the user to pick a credit card type before sending the order to Worldpay (See attached screenshot).
As you all know, the more screens the user has to enter information, the less likely he/she is to buy so this at least eliminates one screen (assuming you only want to accept payment in one currency)
There are only two files to change:
- \includes\templates\YOUR TEMPLATE\templates\tpl_checkout_payment_default.php
- \includes\modules\payment\worldpay.php
File#1
LOOK for the first line in the snippet below then add everything after <!-- BOF Draw CC dropdown box -->
NOTE: This assumes that Worldpay is the FIRST payment module in your sort order. If not then change the value of $i (see comments)
<label for="pmt-<?php echo $selection[$i]['id']; ?>" class="radioButtonLabel"><?php echo $selection[$i]['module']; ?></label>
<!-- BOF Draw CC dropdown box -->
<?php
//This assumes that the Worldpay is your FIRST in your sort order in the ADMIN > Payment > Modules
//If not then change the value of $i to match where in the order you want it
if ($i==0)
{
//Create the array of credit cards as per Worldpay documentation
$cc1[] = array('id' => 'VISA', 'text' => 'Visa');
$cc1[] = array('id' => 'MSCD', 'text' => 'MasterCard');
echo zen_draw_pull_down_menu("paymentType", $cc1,'','','');
}
?>
<!-- EOF Draw CC dropdown box -->
File#2
There are two spots you need to add code.
- LOOK for the first line of code then add the code following it:
$OrderAmt = number_format($order->info['total'] * $currencies->get_value($currency), $currencies->get_decimal_places($currency), '.', '') ;
//**************************************
// Credit card Drop down
//**************************************
//Get the CC type
$CCpaymentType = $_POST["paymentType"];
//**************************************
- In the variable $process_button_string add this line. I put it after this:
zen_draw_hidden_field('currency', $currency) .
//**************************************
// Credit card Drop down
//**************************************
zen_draw_hidden_field('paymentType', $CCpaymentType) .
And that's basically it. You can add more cards by adding it to the array.
Now please bear in mind I am new to Zencart and relatively new to PHP, but I do have 25+ years in coding so I am not completely green but it doesnt mean I couldnt have overlooked something. So go easy on me. But so far it appears to work as planned.
Hopefully Philip will include this in his new version. His work has saved me a lot of time, so thanks Philip!