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

#   Reload Checkout custom fields on shipping change

##

- **[kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")**
- [![kaurovs's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/57689-kaurovs "View kaurovs's Profile") Topic Author
- [ Offline](/forum/user/57689-kaurovs)

Less More

- Posts: 6
- Thank you received: 0
-
-

8 years 4 weeks ago [\#299924](#299924) by [kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")  *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#299924 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")* was created by *[kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")*

-- HikaShop version -- : 4.0.0
-- Joomla version -- : 3.8.13
-- PHP version -- : 7.1.21

Hello!

First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.

I have done that "show_block_fields.php" view understands which shipping_id is selected but only after full browser refresh button pressed (or F5) it gives the real value.
So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.

- [ ![Capture.PNG](/forum/attachment/45249) ](/forum/attachment/45249 "Capture.PNG") [ ](/forum/attachment/45249?download=1 "Capture.PNG")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

8 years 1 month ago [\#299926](#299926) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#299926 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hi,

You should be able to do that with such javascript code: Code:

window.Oby.registerAjax(['checkout.shipping.updated'], function(params){ // shipping has been changed });

However, since you already have a registerAjax function in the show_block_field view file which refresh the fields block with the cart is updated, you could simply add the checkout.shipping.updated event to the list of events already registered there : Code:

window.Oby.registerAjax(['checkout.fields.updated','cart.updated'], function(params){ window.checkout.refreshFields(&lt;?php echo (int)$this-&gt;step; ?&gt;, &lt;?php echo (int)$this-&gt;module_position; ?&gt;); });

The following user(s) said Thank You: [kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")

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

- **[kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")**
- [![kaurovs's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/57689-kaurovs "View kaurovs's Profile") Topic Author
- [ Offline](/forum/user/57689-kaurovs)

Less More

- Posts: 6
- Thank you received: 0
-
-

8 years 1 month ago [\#299934](#299934) by [kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")  Replied by *[kaurovs](/forum/user/57689-kaurovs "View kaurovs's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#299934 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Thank You nicolas!

That's what I needed!

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

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile")
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

6 years 6 months ago [\#319244](#319244) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#319244 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hikashop 4.2.3

I want to refresh custom fields when a different shipping method selected.
Selecting shipping method and pressing F5 works fine.

I've tried adding this line to *show\_block\_shipping.php* and nothing I try (lines 255 or 268) refreshes the fields. Code:

window.checkout.refreshFields(&lt;?php echo (int)$this-&gt;step; ?&gt;, &lt;?php echo (int)$this-&gt;module_position; ?&gt;);

Where should I place it?

Rather than changing the template view an ideal solution would be a Joomla Hikashop plugin event which could be used to trigger this refresh. Then don't have to touch the view!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

6 years 6 months ago [\#319253](#319253) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#319253 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hi,

What you want to do is simply to change the line: Code:

window.Oby.registerAjax(['checkout.fields.updated','cart.updated'], function(params){

to: Code:

window.Oby.registerAjax(['checkout.fields.updated','cart.updated','checkout.shipping.updated'], function(params){

in the file checkout / show_block_fields.php view file so that it refreshes itself when the shipping is updated.

If you want to do it in a plugin, it's possible. You want to implement the trigger onCheckoutStepDisplay($layout, &amp;$ret, &amp;$obj, $pos, $options)
and use such code : Code:

function onCheckoutStepDisplay($layout, &amp;$ret, &amp;$obj, $pos, $options) { if($layout!='fields') return; echo "&lt;script&gt; window.Oby.registerAjax(['checkout.shipping.updated'], function(params){ window.checkout.refreshFields(". (int)$obj-&gt;step.", ".(int)$pos."); } &lt;/script&gt;"; }

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

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile")
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

6 years 6 months ago [\#319658](#319658) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#319658 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Thanks changing the view file worked great, although that's not my ideal solution.

However for my preferred solution the trigger *onCheckoutStepDisplay($layout, &amp;$ret, &amp;$obj, $pos, $options)* is not being called.

Worked around that using this instead - I set pos to 0, is that a good idea? Code:

function onHikashopBeforeDisplayView(&amp;$view) { if (get_class($view) == 'CheckoutViewCheckout') { echo "&lt;script&gt; window.Oby.registerAjax(['checkout.shipping.updated'], function(params){ window.checkout.refreshFields(" . (int)$view-&gt;step . ", 0); }) &lt;/script&gt;"; } }

An alternative would be to call *ob\_start()* in *onHikashopBeforeDisplayView* and then finding and changing the *window.Oby.registerAjax* call in the html returned by *ob\_get\_clean()* in *onHikashopAfterDisplayView* trigger.

Other suggestions - ideas why *onCheckoutStepDisplay* not be being called?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

6 years 6 months ago [\#319673](#319673) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#319673 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hi,

Ah yes, onCheckoutStepDisplay will only be called for the plugin corresponding to a view added to the checkout workflow. That's why it was not triggered since you don't have a view for your plugin.
In that case onHikashopBeforeDisplayView is indeed better.
Note however that you can't put 0 for pos. It needs to be the position of the "fields" view on the current step.
You'll have to do a loop on Code:

$view-&gt;workflow['steps'][$view-&gt;workflow_step]['content']

to get the pos of the fields view.
In that array, each element will be a view. The key of that element in the array will be the pos of the view on the current step. And the value will be an array with Code:

$element['task']

containing the name of the view.

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

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile")
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

6 years 6 months ago [\#319706](#319706) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#319706 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Thanks for the explanation.

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

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile")
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

6 years 5 months ago [\#321268](#321268) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#321268 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Got this half-working now, problem I have is triggering changes when a custom field is changed.

This is my test example - ignoring what I want to do when change event occurs!
Comments below are self-explanatory.
Code:

window.Oby.registerAjax(['checkout.shipping.updated'], function(params){ // Appears OK when shipping changed alert('Test1'); }); window.Oby.registerAjax(['checkout.fields.updated'], function(params){ // Does appear when select custom field on order table changed alert('Test2'); });

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

6 years 5 months ago [\#321270](#321270) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#321270 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hi,

So it looks like it's working. What is your question with this ?

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

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile")
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

6 years 5 months ago [\#321300](#321300) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#321300 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Sorry, did not make myself clear ... this alert does not appear when an order custom field (select) changed. Code:

window.Oby.registerAjax(['checkout.fields.updated'], function(params){ // Does appear when select custom field on order table changed alert('Test2'); });

One solution would be to change the field onchange(...) adding this to the end - i.e. emulating the update additional fields button. Code:

window.checkout.submitFields(3,0);

I'd prefer the ajax when fields updated solution.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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")
- [ Offline](/forum/user/63-nicolas)

Less More

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

6 years 5 months ago [\#321307](#321307) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Reload Checkout custom fields on shipping change](/forum/27-checkout/896121-reload-checkout-custom-fields-on-shipping-change#321307 "-- HikaShop version -- : 4.0.0 -- Joomla version -- : 3.8.13 -- PHP version -- : 7.1.21  Hello!  First of all I want to say that I enjoy to build web shop with Hikashop. I am creating on-page checkout and all things are going well. I need to make costumers possibility to choose one of predefined shipping addresses. I did it with custom drop-down field which is perfect. There is only one thing I cant do by myself. The problem is that I want this Drop-down option to show only for one of three shipping options.  I have done that &quot;show&#95;block&#95;fields.php&quot; view understands which shipping&#95;id is selected but only after full browser refresh button pressed (or F5) it gives the real value. So I need than after changing shipping method AJAX is reloading also Fields block, not only Payment and Cart blocks.")*

Hi,

Ah, I see what you mean. You want to be triggered directly when the onchange happens on any custom order field, and not after the fields are submitted.

In that case, I would recommend to use the addEventListener javascript function to add your own callback to the onchange of each custom field.
You can get the list of the custom fields by searching for all the input tags inside the div of the custom fields area using the javascript function querySelectorAll

The following user(s) said Thank You: [brainforge](/forum/user/423-brainforge "View brainforge's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5NjEyMS1yZWxvYWQtY2hlY2tvdXQtY3VzdG9tLWZpZWxkcy1vbi1zaGlwcGluZy1jaGFuZ2U/dG1wbD1tYXJrZG93bg==) 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.089 seconds

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