[Skip to main content](#vessel-content)

#   Same Initial Billing Address and Shipping Address

##

- **[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")**
- [![Ed&#95;Hika's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile") Topic Author
- [ Offline](/forum/user/33922-ed-hika)

Less More

- Posts: 109
- Thank you received: 5
-
-

11 years 6 months ago [\#200629](#200629) by [Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")  *[Same Initial Billing Address and Shipping Address](/forum/27-checkout/876757-same-initial-billing-address-and-shipping-address#200629 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.8.11  Hello, there.  Good evening!  In the before&#95;address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).  Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?  This problem occurs when the &quot;Checkout&quot; button is clicked.  Thanks.  Take care!")* was created by *[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")*

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.8.11

Hello, there.

Good evening!

In the before_address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).
Code:

if($user_id){ $app = JFactory::getApplication(); $shipping = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.shipping_address',0 ); $billing = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.billing_address',0 );

Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?

This problem occurs when the "Checkout" button is clicked.

Thanks.

Take care!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3Njc1Ny1zYW1lLWluaXRpYWwtYmlsbGluZy1hZGRyZXNzLWFuZC1zaGlwcGluZy1hZGRyZXNzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

11 years 6 months ago [\#200637](#200637) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Same Initial Billing Address and Shipping Address](/forum/27-checkout/876757-same-initial-billing-address-and-shipping-address#200637 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.8.11  Hello, there.  Good evening!  In the before&#95;address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).  Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?  This problem occurs when the &quot;Checkout&quot; button is clicked.  Thanks.  Take care!")*

Hi,

It's normal that when you access the checkout you get the same address selected by default. The system just take the first address and select it for both billing and shipping.

If you want to change the way the system selects the default shipping and billing addresses on the checkout, you want to change the code: Code:

$db = JFactory::getDBO(); $db-&gt;setQuery('SELECT address_id FROM '.hikashop_table('address').' WHERE address_published=1 AND address_user_id='.$user_id); $address_id = $db-&gt;loadResult(); $app-&gt;setUserState( HIKASHOP_COMPONENT.'.shipping_address',$address_id ); $app-&gt;setUserState( HIKASHOP_COMPONENT.'.billing_address',$address_id );

in the file components/com_hikashop/controllers/checkout.php
But I can't say what to do since I don't understand what you want. There are no "existing billing address and shipping address" for a user account. All the addresses of a user can be used for both billing and shipping.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3Njc1Ny1zYW1lLWluaXRpYWwtYmlsbGluZy1hZGRyZXNzLWFuZC1zaGlwcGluZy1hZGRyZXNzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")**
- [![Ed&#95;Hika's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile") Topic Author
- [ Offline](/forum/user/33922-ed-hika)

Less More

- Posts: 109
- Thank you received: 5
-
-

11 years 6 months ago [\#200692](#200692) by [Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")  Replied by *[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")* on topic *[Same Initial Billing Address and Shipping Address](/forum/27-checkout/876757-same-initial-billing-address-and-shipping-address#200692 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.8.11  Hello, there.  Good evening!  In the before&#95;address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).  Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?  This problem occurs when the &quot;Checkout&quot; button is clicked.  Thanks.  Take care!")*

Thanks for the prompt response, Nicolas. Much appreciated.

However, changing the code that you refer to doesn't help with changing the default shipping and billing addresses.

The default shipping and billing addresses are already set in the __construct function in the file components/com_hikashop/controllers/checkout.php. As a test, I have added the following code into the __construct function. Code:

function __construct($config = array(),$skip=false) { dumpMessage('in __contstruct in controllers/checkout.php'); $app = JFactory::getApplication(); $temp1 = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.shipping_address',0 ); $temp2 = $app-&gt;getUserState( HIKASHOP_COMPONENT.'.billing_address',0 ); dump($temp1, '$temp1 in __construct'); dump($temp2, '$temp2 in __construct');

The results are as attached.

As per the results, the default values are already set in the __construct function (presumably when the user logs in).

Please let me know where these values are set; I think they are set even before the before_address function that you refer to in your code below.

Thanks.

Take care!

- [ ![DefaultBillingandShippingAddresses1.png](/forum/attachment/24241) ](/forum/attachment/24241 "...Addresses1.png") [ ](/forum/attachment/24241?download=1 "...Addresses1.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3Njc1Ny1zYW1lLWluaXRpYWwtYmlsbGluZy1hZGRyZXNzLWFuZC1zaGlwcGluZy1hZGRyZXNzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14326
-
-

11 years 6 months ago [\#200718](#200718) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Same Initial Billing Address and Shipping Address](/forum/27-checkout/876757-same-initial-billing-address-and-shipping-address#200718 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.8.11  Hello, there.  Good evening!  In the before&#95;address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).  Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?  This problem occurs when the &quot;Checkout&quot; button is clicked.  Thanks.  Take care!")*

Hi,

It depends how you test actually.
But yes, it would be possible that these were already set before.
In that case, you want to look at the code: Code:

$app-&gt;setUserState( HIKASHOP_COMPONENT.'.shipping_address', $address-&gt;address_id ); $app-&gt;setUserState( HIKASHOP_COMPONENT.'.billing_address', $address-&gt;address_id );

in the onLoginUser function of the plugins/system/hikashopuser/hikashopuser.php file.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3Njc1Ny1zYW1lLWluaXRpYWwtYmlsbGluZy1hZGRyZXNzLWFuZC1zaGlwcGluZy1hZGRyZXNzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")**
- [![Ed&#95;Hika's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile") Topic Author
- [ Offline](/forum/user/33922-ed-hika)

Less More

- Posts: 109
- Thank you received: 5
-
-

11 years 6 months ago [\#200936](#200936) by [Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")  Replied by *[Ed\_Hika](/forum/user/33922-ed-hika "View Ed&#95;Hika's Profile")* on topic *[Same Initial Billing Address and Shipping Address](/forum/27-checkout/876757-same-initial-billing-address-and-shipping-address#200936 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.8.11  Hello, there.  Good evening!  In the before&#95;address function in controllers/checkout.php, the following code retrieves the same address ID for both billing address and shipping address (even though the IDs for the existing billing address and shipping address are different).  Please could you let me know where the billing address and shipping address IDs are set in the user states and how to correct this problem?  This problem occurs when the &quot;Checkout&quot; button is clicked.  Thanks.  Take care!")*

Thanks, Nicolas.

That's great; exactly what I am after.

Take care!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3Njc1Ny1zYW1lLWluaXRpYWwtYmlsbGluZy1hZGRyZXNzLWFuZC1zaGlwcGluZy1hZGRyZXNzP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.070 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
