You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Hi,
Where would I put logic for the payment method(s) to display depending on destination?
That is, if the customer billing address is in the US, they can use either the merchant account (non-PayPal) or PayPal.
If international, then PayPal is the only option that will display.
Thanks!
Offline
Coding would be done in the cogateways() function in the ECOM_Checkout class ({private}/apps/ecom/ECOM_Checkout/ECOM_Checkout.php). Look in there and you will see the gateways are pulled via SQL and after the result is formulated you can loop through them and do what you wish.
Offline
Hi Nick,
I have been trying to create a mod to restrict Worldpay to certain countries. I am able to pick up the billing address by accessing the cogetaddress sub-routine (the $wpcountry variable). I am using the billing address at the moment. I would prefer to use the delivery address but I am unable to reference it - called ($wpscountry) in my code snippet below. I have tried many statements from the ECOM_Checkout.php module but every one returns a null value. My latest attempt is below.
$address =$this->cogetaddress();
$wpcountry = ($address['country']);
$info = $this-->globals('ecom.customship');
$wpscountry = $info['country'];
foreach ($gateways as $num => $row) {
if ($row['id'] == 'paypalproe') {
if ($gateway_select != 'paypalproe') {unset($gateways[$num]);}
} else {
if ($gateway_select == 'paypalproe') {unset($gateways[$num]);}
} // End of if statement.
if ($row['id'] == 'worldpaytest') {
if (($wpcountry == "UK - England & Wales")||($wpcountry == "UK - Scotland Mainland")||($wpcountry == "UK - Highlands & Islands Scotland")||($wpcountry == "UK - Isle of Man")||($wpcountry == "UK - Isles of Scilly")||($wpcountry == "UK - Channel Islands")||($wpcountry == "UK - Northern Ireland")){
print ($row['id']); print ' is available in ' ;print $wpcountry;
continue;
}else{
print ($row['id']); print ' is not available in ' ;print $wpcountry;
{unset($gateways[$num]);}
} // end of if statement
}
How do I pick up the delivery address rather than the billing address?
Any help appreciated.
Regards,
Kevin
Offline
Getting the shipping address in checkout is a bit complicated as it's stored on the item level and could be different, or not there depending on item delivery status. I'd recommend adding this to your code, and executing it:
print '<pre>' . print_r($this->cosess,1) . '</pre>';
The checkout session variable ($this->cosess) holds an array of items matched to delivery addresses, which show up in the user's address book, referenced with:
$this->globals('core_session.addbook');
To pick up the first valid address:
$addbook = $this->globals('core_session.addbook'); $deladd = array(); foreach ($this->cosess['items'] as $cartid => $item) { if ($item['delgroup'] == 'UNASSIGNED') {continue;} if (empty($addbook[$item['deladd']])) {continue;} $deladd = $addbook[$item['deladd']]; break 1; } // End of foreach statement. if (!(empty($deladd))) {print '<p>Delivery address is: ' . print_r($deladd,1) . '</p>';}
Offline