Hi
I've been a long time lurker here and on my site, http://www.naturallytots.com, I encountered a problem that I noticed was not really answered here.
I recently got an order from Australia and the order was rejected.
After seeing on page 1 of this thread that Beanstream requires the province to be "--" if the country is not Canada or US, I finally figured out this change.
In beanstream.php, at line 290 change:
Code:
if (strlen($order->billing['state']) > 2) {
$sql = "SELECT zone_code FROM " . TABLE_ZONES . " WHERE zone_name = :zoneName";
$sql = $db->bindVars($sql, ':zoneName', $order->billing['state'], 'string');
$state = $db->Execute($sql);
$province_code_order = (!$state->EOF) ? $state->fields['zone_code'] : '--';
}
$province_code_ship = (in_array($order->delivery['country']['iso_code_2'], array('CA', 'US')) ? zen_get_zone_code($order->delivery['country']['id'], $order->delivery['state'], '--') : '--');
if (strlen($order->delivery['state']) > 2) {
$sql = "SELECT zone_code FROM " . TABLE_ZONES . " WHERE zone_name = :zoneName";
$sql = $db->bindVars($sql, ':zoneName', $order->delivery['state'], 'string');
$state = $db->Execute($sql);
$province_code_ship = (!$state->EOF) ? $state->fields['zone_code'] : '--';
}
to
Code:
if (in_array($order->billing['country']['iso_code_2'], array('CA','US'))) {
if (strlen($order->billing['state']) > 2 ) {
$sql = "SELECT zone_code FROM " . TABLE_ZONES . " WHERE zone_name = :zoneName";
$sql = $db->bindVars($sql, ':zoneName', $order->billing['state'], 'string');
$state = $db->Execute($sql);
$province_code_order = (!$state->EOF) ? $state->fields['zone_code'] : '--';
}
}
$province_code_ship = (in_array($order->delivery['country']['iso_code_2'], array('CA', 'US')) ? zen_get_zone_code($order->delivery['country']['id'], $order->delivery['state'], '--') : '--');
if (in_array($order->delivery['country']['iso_code_2'], array('CA','US'))) {
if (strlen($order->delivery['state']) > 2 ) {
$sql = "SELECT zone_code FROM " . TABLE_ZONES . " WHERE zone_name = :zoneName";
$sql = $db->bindVars($sql, ':zoneName', $order->delivery['state'], 'string');
$state = $db->Execute($sql);
$province_code_ship = (!$state->EOF) ? $state->fields['zone_code'] : '--';
}
}
The lines
Code:
$province_code_order = (in_array($order->billing['country']['iso_code_2'], array('CA', 'US')) ? zen_get_zone_code($order->billing['country']['id'], $order->billing['state'], '--') : '--');
and
Code:
$province_code_ship = (in_array($order->delivery['country']['iso_code_2'], array('CA', 'US')) ? zen_get_zone_code($order->delivery['country']['id'], $order->delivery['state'], '--') : '--');
assign "--" as the billing and shipping province if the billing and shipping province is not Canada or US.
The IF statements I added above ensure that the province code, which is assigned by the SQL statements from lines 291 to 293 and 298 to 300, only happens if the country is Canada or US.
I noticed without these extra IF statements, even though the province/state is set to "--", the SQL statements reassign it back to QLD (for Queensland state in my case) which will cause Beanstream to reject the transaction.
This code change seems to work. It probably needs more testing though.
Bookmarks