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)
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
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
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 );
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