- Posts: 7
- Thank you received: 0
Verification function of Postcode needed - Auspost
14 years 4 months ago #48957
by tekwizard
Verification function of Postcode needed - Auspost was created by tekwizard
When a customer enters the wrong postcode then this leads to a $0 postage fee.
This happens easily from an Apple computer with Safari with the Autofill function - the postcode is not properly inserted - instead the address data (street/number) ends up in the postcode field as well. There need to be a function to validate the postcode (in Australia numeric/4digits) and produce an error message before processing the final check-out.
This happens easily from an Apple computer with Safari with the Autofill function - the postcode is not properly inserted - instead the address data (street/number) ends up in the postcode field as well. There need to be a function to validate the postcode (in Australia numeric/4digits) and produce an error message before processing the final check-out.
Please Log in or Create an account to join the conversation.
14 years 4 months ago #49035
by nicolas
Replied by nicolas on topic Re: Verification function of Postcode needed - Auspost
Hi,
Change the code:
to:
in the file plugins/hikashopshipping/aupost.php and that should do the job.
Change the code:
Code:
if(empty($order->shipping_address->address_post_code)){
$zoneClass=hikashop_get('class.zone');
$zones = $zoneClass->getOrderZones($order);
$db =& JFactory::getDBO();
$db->setQuery('SELECT zone_namekey FROM '.hikashop_table('zone').' WHERE zone_code_3='.$db->Quote('AUS'));
$australia_zone = $db->loadResult();
if(in_array($australia_zone,$zones)){
$messages['post_code_missing'] = 'The Australia Post shipping plugin requires the user to enter a postal code when goods are shipped within Australia. Please go to "Display->Custom fields" and set the post code field to required.';
continue;
}
}
Code:
$check = false;
if(empty($order->shipping_address->address_post_code)){
$check = true;
$message = 'The Australia Post shipping plugin requires the user to enter a postal code when goods are shipped within Australia. Please go to "Display->Custom fields" and set the post code field to required.';
}elseif(!preg_match('#[0-9]{4}#',$order->shipping_address->address_post_code)){
$check = true;
$message = 'The post code entered is not valid';
}
if($check){
$zoneClass=hikashop_get('class.zone');
$zones = $zoneClass->getOrderZones($order);
$db =& JFactory::getDBO();
$db->setQuery('SELECT zone_namekey FROM '.hikashop_table('zone').' WHERE zone_code_3='.$db->Quote('AUS'));
$australia_zone = $db->loadResult();
if(in_array($australia_zone,$zones)){
$messages['post_code_missing'] = $message;
continue;
}
}
Please Log in or Create an account to join the conversation.
14 years 4 months ago #49038
by Mike2001
Replied by Mike2001 on topic Re: Verification function of Postcode needed - Auspost
Would this be easy to change for use in the USPS plug in? If not could I get you to help me with it?
Please Log in or Create an account to join the conversation.
14 years 4 months ago #49057
by tekwizard
Replied by tekwizard on topic Re: Verification function of Postcode needed - Auspost
Thanks for the quick fix - I have tested it and it works good. Are you publishing an official version of the Auspost plugin soon with all the changes? Or are they already included in the official packages? We are considering getting the business version soon and want to make sure the version will be up to date.
Please Log in or Create an account to join the conversation.
14 years 4 months ago #49132
by nicolas
Replied by nicolas on topic Re: Verification function of Postcode needed - Auspost
The same code is used int he USPS plugin:
So you can do the same modification:
The aupost being included in HikaShop, the modification will be in next version of HikaShop.
It won't be added until then, but you can just reapply it after upgrading if you want to upgrade before the next version.
Code:
if(empty($order->shipping_address->address_post_code)){
$zoneClass=hikashop_get('class.zone');
$zones = $zoneClass->getOrderZones($order);
$db =& JFactory::getDBO();
$db->setQuery('SELECT zone_namekey FROM '.hikashop_table('zone').' WHERE zone_code_3='.$db->Quote('USA'));
$usa_zone = $db->loadResult();
if(in_array($us_zone,$zones)){
$messages['post_code_missing'] = 'The USPS shipping plugin requires the user to enter a postal code when goods are shipped within the United States. Please go to "Display->Custom fields" and set the post code field to required.';
continue;
}
}
So you can do the same modification:
Code:
$check = false;
if(empty($order->shipping_address->address_post_code)){
$check = true;
$message = 'The USPS shipping plugin requires the user to enter a postal code when goods are shipped within the United States. Please go to "Display->Custom fields" and set the post code field to required.';
}elseif(!preg_match('#^[0-9]{5}(-?[0-9]{4})?$#',$order->shipping_address->address_post_code)){
$check = true;
$message = 'The post code entered is not valid';
}
if($check){
$zoneClass=hikashop_get('class.zone');
$zones = $zoneClass->getOrderZones($order);
$db =& JFactory::getDBO();
$db->setQuery('SELECT zone_namekey FROM '.hikashop_table('zone').' WHERE zone_code_3='.$db->Quote('USA'));
$usa_zone = $db->loadResult();
if(in_array($usa_zone,$zones)){
$messages['post_code_missing'] = $message;
continue;
}
}
The aupost being included in HikaShop, the modification will be in next version of HikaShop.
It won't be added until then, but you can just reapply it after upgrading if you want to upgrade before the next version.
The following user(s) said Thank You: Mike2001
Please Log in or Create an account to join the conversation.
14 years 4 months ago #49620
by Mike2001
Replied by Mike2001 on topic Re: Verification function of Postcode needed - Auspost
Thanks again Nicolas...
Please Log in or Create an account to join the conversation.
Time to create page: 0.242 seconds