- Posts: 175
- Thank you received: 0
Add Address via Script.. is there any API ?
10 years 3 months ago #242963
by veeco
Add Address via Script.. is there any API ? was created by veeco
-- HikaShop version -- : 2.6.3
Hello,
i have a custom checkout, i need to add address via script.. is there any API that handle this ? if not, can you point me which script that done this process.. i will try to duplicate the script in my custom script
Thanks
Hello,
i have a custom checkout, i need to add address via script.. is there any API that handle this ? if not, can you point me which script that done this process.. i will try to duplicate the script in my custom script
Thanks
Please Log in or Create an account to join the conversation.
10 years 3 months ago #242965
by nicolas
Replied by nicolas on topic Add Address via Script.. is there any API ?
Hi,
I would recommend to have a look at the code of the the PayPal Express plugin where it creates an address based on the data provided by PayPal:
You can find that in plugins/hikashoppayment/paypalexpress/
I would recommend to have a look at the code of the the PayPal Express plugin where it creates an address based on the data provided by PayPal:
Code:
$address = $this->createAddress($vars,$userid);
$addressClass = hikashop_get('class.address');
$addressid = $addressClass->save($address);
function createAddress($vars,$userid) {
if (empty($userid) )
return false;
else {
$db = JFactory::getDBO();
if(!empty($vars['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] ) ) {
$db->setQuery('SELECT zone_namekey FROM `#__hikashop_zone` WHERE zone_code_2 = '.
$db->Quote($vars['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']).' AND zone_type = \'country\';');
$country = $db->loadResult();
}
if (empty($country) ) {
$db->setQuery('SELECT zone_namekey FROM `#__hikashop_zone` WHERE zone_name_english = '.
$db->Quote($vars['PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME']).' AND zone_type = \'country\';');
$country = $db->loadResult();
if (empty($country))
$country = $vars['PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME'];
}
if (empty($vars['PAYMENTREQUEST_0_SHIPTOSTATE'] ) )
$state = "NULL";
else {
$db->setQuery('SELECT zone_namekey FROM `#__hikashop_zone` WHERE zone_code_2 = '
.$db->Quote($vars['PAYMENTREQUEST_0_SHIPTOSTATE']).' AND zone_type = \'state\';');
$state = $db->loadResult();
if (empty($state) )
$state = $vars['PAYMENTREQUEST_0_SHIPTOSTATE'];
}
$address = new stdClass();
$address->address_user_id = $userid;
$address->address_firstname = $vars['FIRSTNAME'];
$address->address_lastname = $vars['LASTNAME'];
$address->address_street = $vars['PAYMENTREQUEST_0_SHIPTOSTREET'];
$address->address_post_code = $vars['PAYMENTREQUEST_0_SHIPTOZIP'];
$address->address_city = $vars['PAYMENTREQUEST_0_SHIPTOCITY'];
$address->address_state = $state;
$address->address_country = $country;
}
return $address;
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.137 seconds