Override shipping address, possible?

  • Posts: 88
  • Thank you received: 19
7 years 8 months ago #265129

-- HikaShop version -- : 3.0.0
-- Joomla version -- : 3.6.5

Hi

I've put together a custom shipping plugin. I would like to use the function onShippingDisplay to inject a custom shipping address as the users delivery address, but I don't know how to address those fields, if possible?

Any advice is appreciated.

Thanks

Last edit: 7 years 8 months ago by dyvel.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
7 years 8 months ago #265130

Hi,

You can't use the getShippingAddress to inject a custom shipping address as a normal shipping address.
The getShippingAddress allows you to completely replace the shipping address interfaces to only display your text.
So for example, you can store your address data in a custom field of the table "order", and in the getShippingAddress function you can just return the HTML of your address that you want to appear instead of the normal shipping address interface.
Or you could implement the onBeforeOrderCreate function and replace the shipping address fields in $order by your own data.
That way, the address would be replaced when the order is created and it would act like a normal shipping address, that you can edit in the order backend interface, etc.

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

  • Posts: 88
  • Thank you received: 19
7 years 8 months ago #265148

onBeforeOrderCreate looks like the way to go. Thanks.

I can see I have selected shipping data in $order->shipping. I can see the content through &$order->shipping but seem to access the content ? I was thinking of storing the data in a session variable, and then use that onBeforeOrderCreate.

Is it possible to access the data?

Thanks

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

  • Posts: 88
  • Thank you received: 19
7 years 8 months ago #265162

How can I override users shipping address onBeforeOrderCreate?
I tried the following without luck:

function onBeforeOrderCreate(&$order,&$send_email) {
	$order->cart->shipping_address->address_lastname = 'Smith';
}

Last edit: 7 years 8 months ago by dyvel.

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

  • Posts: 12953
  • Thank you received: 1778
7 years 8 months ago #265163

Hello,

What do you exactly mean by "Is it possible to access the data?" ?
Note that the "onBeforeOrderCreate" trigger is launched during the "end" step of your checkout workflow.

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

  • Posts: 88
  • Thank you received: 19
7 years 8 months ago #265220

I mean the data that is stored in $order->shipping - I can see the data, but when I try to access it, I just get null/nothing

Last edit: 7 years 8 months ago by Jerome. Reason: removing useless quote

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
7 years 8 months ago #265245

Hi,

$order->cart is only the content of the cart.
What you need to do is this :
get the address_id of the shipping address in that variable: $order->order_shipping_address_id
And then you can save the new data with the HikaShop address class like that:

$shipping = new stdClass();
$shipping->address_id = $order->order_shipping_address_id;
$shipping->address_lastname = 'smith';
$addressClass = hikashop_get('class.address');
$addressClass->save($shipping);

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

Time to create page: 0.086 seconds
Powered by Kunena Forum