Last active
April 19, 2024 10:55
-
-
Save xlplugins/3beedb8956e3d1c4a752654e776b07b2 to your computer and use it in GitHub Desktop.
move collapsible order summary below payment gateway
This file contains 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 FunnelKitMoveSectionBelowGateway { | |
public function __construct() { | |
add_action( 'wfacp_internal_css', [ $this, 'css' ] ); | |
add_action( 'wfacp_after_gateway_list', [ $this, 'move_collapsisble' ] ); | |
add_filter( 'wfacp_display_place_order_buttons', [ $this, 'hide_place_order' ] ); | |
add_action( 'woocommerce_review_order_after_payment', [ $this, 'print_order_button' ], 12 ); | |
} | |
public function css() { | |
?> | |
<style> | |
.wfacp_collapsible_order_summary_wrap { | |
display: none | |
} | |
#wfacp_bottom_collapsible .wfacp_collapsible_order_summary_wrap { | |
display: block; | |
} | |
div#wfacp_bottom_collapsible { | |
margin-top: 25px; | |
} | |
</style> | |
<script> | |
window.addEventListener('load', function () { | |
(function ($) { | |
function push() { | |
let collapse = document.getElementsByClassName('wfacp_collapsible_order_summary_wrap'); | |
let copy = collapse[0].cloneNode(true); | |
if (collapse.length > 0) { | |
$('#wfacp_bottom_collapsible').html(""); | |
document.getElementById('wfacp_bottom_collapsible').append(copy); | |
} | |
} | |
push(); | |
jQuery('body').on('updated_checkout', function () { | |
setTimeout(push, 500); | |
}); | |
})(jQuery); | |
}); | |
</script> | |
<?php | |
} | |
public function move_collapsisble() { | |
echo "<div id='wfacp_bottom_collapsible'></div>"; | |
} | |
public function hide_place_order() { | |
return false; | |
} | |
public function print_order_button() { | |
$order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) ); | |
?> | |
<div class="form-row place-order"> | |
<noscript> | |
<?php esc_html_e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?> | |
<br/> | |
<button type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>"><?php esc_html_e( 'Update totals', 'woocommerce' ); ?></button> | |
</noscript> | |
<?php wc_get_template( 'checkout/terms.php' ); ?> | |
<?php | |
do_action( 'woocommerce_review_order_before_submit' ); | |
do_action( 'wfacp_woocommerce_review_order_before_submit' ); | |
echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); // @codingStandardsIgnoreLine | |
do_action( 'wfacp_woocommerce_review_order_after_submit' ); | |
do_action( 'woocommerce_review_order_after_submit' ); | |
?> | |
</div> | |
<?php | |
} | |
} | |
new FunnelKitMoveSectionBelowGateway(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment