- Posts: 88
- Thank you received: 20
Override shipping address, possible?
9 years 6 months ago - 9 years 6 months ago #265129
by dyvel
Override shipping address, possible? was created by dyvel
-- 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
-- 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: 9 years 6 months ago by dyvel.
Please Log in or Create an account to join the conversation.
9 years 6 months ago #265130
by nicolas
Replied by nicolas on topic Override shipping address, possible?
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.
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.
9 years 6 months ago #265148
by dyvel
Replied by dyvel on topic Override shipping address, possible?
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
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.
9 years 6 months ago - 9 years 6 months ago #265162
by dyvel
Replied by dyvel on topic Override shipping address, possible?
How can I override users shipping address onBeforeOrderCreate?
I tried the following without luck:
I tried the following without luck:
Code:
function onBeforeOrderCreate(&$order,&$send_email) {
$order->cart->shipping_address->address_lastname = 'Smith';
}
Last edit: 9 years 6 months ago by dyvel.
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
9 years 6 months ago #265163
by Mohamed Thelji
Replied by Mohamed Thelji on topic Override shipping address, possible?
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.
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.
9 years 6 months ago - 9 years 6 months ago #265220
by dyvel
Replied by dyvel on topic Override shipping address, possible?
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: 9 years 6 months ago by Jerome. Reason: removing useless quote
Please Log in or Create an account to join the conversation.
9 years 6 months ago #265245
by nicolas
Replied by nicolas on topic Override shipping address, possible?
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:
$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:
Code:
$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.249 seconds