- Posts: 109
- Thank you received: 5
Same Initial Billing Address and Shipping Address
11 years 6 months ago #200629
by Ed_Hika
Same Initial Billing Address and Shipping Address was created by Ed_Hika
-- 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).
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!
-- 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->getUserState( HIKASHOP_COMPONENT.'.shipping_address',0 );
$billing = $app->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 or Create an account to join the conversation.
11 years 6 months ago #200637
by nicolas
Replied by nicolas on topic Same Initial Billing Address and Shipping Address
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:
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.
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->setQuery('SELECT address_id FROM '.hikashop_table('address').' WHERE address_published=1 AND address_user_id='.$user_id);
$address_id = $db->loadResult();
$app->setUserState( HIKASHOP_COMPONENT.'.shipping_address',$address_id );
$app->setUserState( HIKASHOP_COMPONENT.'.billing_address',$address_id );
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 or Create an account to join the conversation.
11 years 6 months ago #200692
by Ed_Hika
Replied by Ed_Hika on topic Same Initial Billing Address and Shipping Address
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.
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!
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->getUserState( HIKASHOP_COMPONENT.'.shipping_address',0 );
$temp2 = $app->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!
Please Log in or Create an account to join the conversation.
11 years 6 months ago #200718
by nicolas
Replied by nicolas on topic Same Initial Billing Address and Shipping Address
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:
in the onLoginUser function of the plugins/system/hikashopuser/hikashopuser.php file.
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->setUserState( HIKASHOP_COMPONENT.'.shipping_address', $address->address_id );
$app->setUserState( HIKASHOP_COMPONENT.'.billing_address', $address->address_id );
Please Log in or Create an account to join the conversation.
11 years 6 months ago #200936
by Ed_Hika
Replied by Ed_Hika on topic Same Initial Billing Address and Shipping Address
Thanks, Nicolas.
That's great; exactly what I am after.
Take care!
That's great; exactly what I am after.
Take care!
Please Log in or Create an account to join the conversation.
Time to create page: 0.057 seconds