Get Addresses from another place -outside hikashop

  • Posts: 57
  • Thank you received: 4
9 years 9 months ago #189377

Hi,

I need again your help.
I have a webservice that returns to me all addresses of customers. For that, I have in this webservice params like user_id for example.
This webservice returns to me the billing address and all the rest of the delivery addresses.

So what i want is:

When I'm inside the page "user control panel" and choose for example "Manage my addresses" I will see one table with all the delivery addresses for this user that we have coming from the webservice. And it's only that. We don't do more nothing here. Don't edit, don't add, nothing. Just look.

After that, in checkout where the user choose him addresses the billing address will be auto (comming from the webservice) and the delivery address will be a combobox like we have now where the list of possible addresses will coming from the webservice to. And like we have now, the user will can choose if want the same address that the billing address or another.

After that, when the user finish and submit the cart we have a new order like we have now. But to resolve the problem with addresses, because if we use this webservice, we don't use the database and we don't have addresses inside. So we need to make a function to save addresses only for orders, because if we use the webservice, in future when we try to see the order we will don't find addresses because maybe this user don't have now this address. So the webservice don't return that address and the history will find one error because don't have the same address.
So for this we will need a function to insert this address if the address don't exists in hikashop addresses table. And the order page works normally like now, showing all the correct history.


So in summary, what we need is:

1. The "manage my addresses" in "user control panel" only show the addresses coming from the webservice.
2. The checkout select the billing address and the delivery address from the webservice.
3. After submit the cart we need a function to see if that addresses that we have selected exists in hikashop addresses table. If not exist add this one, and make a normal relation for the order history works perfect.
4. Orders page works like now, showing the address from hikashop addresses table.


I know that is a lot of changes, but can you help me?
Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189395

Hi,

We cannot code that for you (you can contact our partners for a quote if you need someone to develop that for you). We can however tell you what should be coded where in order to achieve that:

1. You can edit the file "listing" of the view "address" via the menu Display>Views. There, remove the code and add your own code to fetch the addresses and display them the way you want.

2. I would recommend to remove the "address" view from the checkout workflow option of the configuration and instead add a custom view that you would add with a custom hikashop plugin.
I would recommend to implement the checkout API of HikaShop :
www.hikashop.com/support/support/documen...tation.html#checkout
That way, you can have your own checkout step and handle the HTML displayed on the step and the saving of the selection completely in your plugin. I would recommend to save the selection somewhere in the user session thanks to $_SESSION.
As an example, you can look at the user points plugin files under the folder plugins/hikashop/userpoints which implement these triggers.

3. I would recommend to implement in your hikashop plugin the trigger onBeforeOrderCreate in order to generate the address if necessary in the table hikashop_address based on the one that was selected and that you stored in the session. Simply add the address_id of the address in $order->order_billing_address_id and $order->order_shipping_address_id and the system will take them into account.

4. There is nothing to do here as you saved the address and linked it in the order as if it was a standard HikaShop address, so the system will display it automatically in the notification emails, the order details page in the backend, in the frontend and in the invoice.

The following user(s) said Thank You: rfernandes

Please Log in or Create an account to join the conversation.

Time to create page: 0.047 seconds
Powered by Kunena Forum