Hi all,
I belive I have a fix for all of you who have problems with virtual products where the delivery fields are not being sent to SagePay :oops:
However you should note this fix is untested, so if you apply this fix the first thing you MUST do is backup your database and server files (sorry about the next bit, but if I don't say it then someone will moan at me if things go wrong) as I will not be held responsable if anything bad happens and you didn't backup everything first.
Ok so here goes
- BACKUP EVERYTHING
- Open includes/modules/payment/sagepay_form.php (in a good text editor such as notepad++)
- find this block of code
$plain .= "DeliverySurname=" . $order->delivery['lastname'] . "&";
$plain .= "DeliveryFirstnames=" . $order->delivery['firstname'] . "&";
$plain .= "DeliveryAddress1=" . $order->delivery['street_address'] . "&";
if (ACCOUNT_SUBURB == 'true') {
$plain .= "DeliveryAddress2=" . $order->delivery['suburb'] . "&";
}
$plain .= "DeliveryCity=" . $order->delivery['city'] . "&";
$plain .= "DeliveryPostCode=" . $order->delivery['postcode'] . "&";
$plain .= "DeliveryCountry=" . $order->delivery['country']['iso_code_2'] . "&";
if (($order->delivery['country']['iso_code_2']) == 'US') {
$orderdelivstate = $order->delivery['state'];
$plain .= "DeliveryState=" . $us_state_codes[$orderdelivstate] . "&";
}else{
$plain .= "DeliveryState=" . "&";
}
$plain .= "DeliveryPhone=" . $order->customer['telephone'] . "";
- replace all of the block of code with the code below
// DeliveryXXX fields
if ($order->delivery['lastname']===NULL) {
$plain .= "DeliverySurname=" . $order->billing['lastname'] . "&";
} else {
$plain .= "DeliverySurname=" . $order->delivery['lastname'] . "&";
}
if ($order->delivery['firstname']===NULL) {
$plain .= "DeliveryFirstnames=" . $order->billing['firstname'] . "&";
} else {
$plain .= "DeliveryFirstnames=" . $order->delivery['firstname'] . "&";
}
if ($order->delivery['street_address']===NULL) {
$plain .= "DeliveryAddress1=" . $order->billing['street_address'] . "&";
} else {
$plain .= "DeliveryAddress1=" . $order->delivery['street_address'] . "&";
}
if (($order->delivery['suburb']===NULL) && (ACCOUNT_SUBURB == 'true')) {
$plain .= "DeliveryAddress2=" . $order->billing['suburb'] . "&";
} elseif ((ISSET($order->delivery['suburb'])) && (ACCOUNT_SUBURB == 'true')) {
$plain .= "DeliveryAddress2=" . $order->delivery['suburb'] . "&";
} else {
$plain .= "DeliveryAddress2=" . "" . "&";
}
if ($order->delivery['city']===NULL) {
$plain .= "DeliveryCity=" . $order->billing['city'] . "&";
} else {
$plain .= "DeliveryCity=" . $order->delivery['city'] . "&";
}
if ($order->delivery['postcode']===NULL) {
$plain .= "DeliveryPostCode=" . $order->billing['postcode'] . "&";
} else {
$plain .= "DeliveryPostCode=" . $order->delivery['postcode'] . "&";
}
if ($order->delivery['country']['iso_code_2']===NULL) {
$plain .= "DeliveryCountry=" . $order->billing['country']['iso_code_2'] . "&";
} else {
$plain .= "DeliveryCountry=" . $order->delivery['country']['iso_code_2'] . "&";
}
if (($order->delivery['country']['iso_code_2']) == 'US') {
$orderdelivstate = $order->delivery['state'];
$plain .= "DeliveryState=" . $us_state_codes[$orderdelivstate] . "&";
}else{
$plain .= "DeliveryState=" . "&";
}
$plain .= "DeliveryPhone=" . $order->customer['telephone'] . "";
- Save the file and upload it
You should now hopefully be all fixed :clap::clap:
If anyone has any problems just post them in here as I have notifications for this thread turned on, so I will know right away :cool:
Regards
Nixak