Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Moving Delivery Date Field in Checkout Page WordPress

  • SOLVED

Hey guys, when Delivery Fee option is selected, I need to change the position of the Delivery Date Field (by WooCommerce Order Delivery plugin) to right below the shipping options selection (woocommerce_review_order_before_payment hook)

Answers (6)

2021-02-13

Arnav Joy answers:

are you using child theme?
can you upload zip file of this plugin so I can have a look on code?


cedlimed comments:

Yes, I'm using child theme
http://freshcollective.sg/wp-content/uploads/2021/02/woocommerce-order-delivery-2.zip

2021-02-13

Mohamed Ahmed answers:

Hello Cedlimed,

Could you add this code into functions.php file and it will do the trick!


add_action('wp_footer', 'customFooterCodes');
function customFooterCodes(){

if(! is_checkout()) return;
?>
<script>
jQuery('#wc-od').insertBefore('.order-total').wrap('<tr></tr>');
</script>
<?php
}


cedlimed comments:

Hi there, I've added this to functions.php but now the Delivery date function is not showing up at all


Mohamed Ahmed comments:

Could you purge the Cloudflare cache then clear your browser cache?
Because the code didn't displaying in the site code
Or you can send to me an account to my email " callmeinstantly @gmail.com " to do it


cedlimed comments:

Hi, same thing though after purging and clearing cache.
The code is already in the site code see this screenshot
https://imgur.com/a/1Tb4uKs
the code is already in effect otherwise the Delivery Date function should still be showing. now it's missing totally from the checkout page.

thanks for your help


Mohamed Ahmed comments:

Hi, your site has a javascript errors that displays in Google chrome console
Press F12 to check it
Like the image https://prnt.sc/zdw6sq
It may that conflict didn't execute the function.
So, try to disable plugins one by one with try the site.


cedlimed comments:

Thanks, have resolved all the JS errors but still the same issue. Delivery date still doesn't show up.


Mohamed Ahmed comments:

Could you send me the plugin files to handle your request


Mohamed Ahmed comments:

This is the solution (tested and working)


add_action('woocommerce_review_order_before_payment', 'ElDigital_customFooterCodes');

function ElDigital_customFooterCodes(){
if(! is_checkout()) return;
?>
<script>
jQuery( document.body ).on( 'updated_checkout', function(){
jQuery('#wc-od').insertBefore('#place_order').wrap('<tr class="wc-od"></tr>');
});
</script>
<?php
}


The result
https://prnt.sc/zo9n9k

Regards

2021-02-13

Francisco Javier Carazo Gil answers:

This is not an standard place for place it. Using PHP you should use some hooks to create a new place and some JS logic to show it.

Using JS you can do it (but this is not so pro) moving from one element of the DOM to another one: https://stackoverflow.com/questions/1279957/how-to-move-an-element-into-another-element

2021-02-14

cedlimed answers:

managed to find the hook in the plugin class-wc-od-checkout.php
add_action( 'woocommerce_checkout_before_customer_details', array( $this, 'checkout_content' ), 99 );

2021-02-15

Bob answers:

Is it possible for you to share plugin?

2021-02-16

Ali mosbah answers:

You must use a JS only but if you want a PHP solution, you must edit to the core of plugin files