Created
May 15, 2026 10:05
-
-
Save rajeshsingh520/1cefb9f38906a146c58745428e964563 to your computer and use it in GitHub Desktop.
move option fee selection to any place on checout page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class pisol_custom_clone_checkbox{ | |
| static $instance = null; | |
| static $run = 0; | |
| static function get_instance(){ | |
| if(is_null(self::$instance)){ | |
| self::$instance = new self(); | |
| } | |
| return self::$instance; | |
| } | |
| function __construct(){ | |
| add_action('woocommerce_checkout_before_order_review', [$this, 'clone_checkbox']); | |
| add_action('wp_enqueue_scripts', [$this, 'enqueue_jquery']); | |
| } | |
| function clone_checkbox(){ | |
| // make sure to run this function only once | |
| if(self::$run > 0) return; | |
| echo '<div id="clone-chekbox-container"></div>'; | |
| self::$run++; | |
| } | |
| function enqueue_jquery(){ | |
| $js = ' | |
| jQuery(document).ready(function($){ | |
| $(document.body).on("updated_checkout", function(){ | |
| $("#clone-chekbox-container").html(""); | |
| var clonedHtml = $("ul.pi-cefw-optional-fees-list").clone(); | |
| clonedHtml.find(".pi-cefw-optional-fees").removeClass("pi-cefw-optional-fees").addClass("pi-cefw-optional-fees-clone"); | |
| $("#clone-chekbox-container").html(clonedHtml); | |
| }); | |
| $(document).on("change", ".pi-cefw-optional-fees-clone", function(){ | |
| var name = $(this).attr("name"); | |
| if($(this).is(":checked")){ | |
| $("input[name=\'"+name+"\'].pi-cefw-optional-fees").prop("checked", true); | |
| }else{ | |
| $("input[name=\'"+name+"\'].pi-cefw-optional-fees").prop("checked", false); | |
| } | |
| $("input[name=\'"+name+"\'].pi-cefw-optional-fees").trigger("change"); | |
| }); | |
| }); | |
| '; | |
| wp_add_inline_script('jquery', $js, 'after'); | |
| $css = " | |
| .optional-fee-container{ | |
| display:none; | |
| } | |
| .pi-condition-fees{ | |
| flex-basis:100% !important; | |
| text-align:left !important; | |
| } | |
| "; | |
| wp_register_style( 'my-inline-style-2026', false ); | |
| wp_enqueue_style( 'my-inline-style-2026' ); | |
| wp_add_inline_style( 'my-inline-style-2026', $css ); | |
| } | |
| } | |
| pisol_custom_clone_checkbox::get_instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment