Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Last active April 28, 2026 12:36
Show Gist options
  • Select an option

  • Save xlplugins/d7cb3598ba08156152c4c97ae01b56be to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/d7cb3598ba08156152c4c97ae01b56be to your computer and use it in GitHub Desktop.
move next button below mini cart
/**
* Move Next Step button below mini cart / order summary total.
* Pure JS approach — works with ALL page builders and templates.
* Add to theme's functions.php or a custom snippet plugin.
*/
add_action( 'wp_footer', 'wfacp_move_next_btn_below_total', 99 );
function wfacp_move_next_btn_below_total() {
if ( ! function_exists( 'wfacp_template' ) || ! wfacp_template() ) {
return;
}
if ( 'single_step' === wfacp_template()->get_current_step() ) {
return;
}
?>
<style>
.wfacp_mc_next_buttons .wfacp_back_cart_link { display: none !important; }
.wfacp_mc_next_buttons .wfacp_next_page_button { transition: filter .15s ease; }
.wfacp_mc_next_buttons .wfacp_next_page_button:hover { filter: brightness(.92); }
</style>
<script>
jQuery(function($) {
if (window.innerWidth < 1024) return;
$(window).on('load', function() { setTimeout(initMcNextBtns, 200); });
function initMcNextBtns() {
if ($('.wfacp_mc_next_buttons').length) return;
// Find target: mini cart widget OR inline order summary
var target = null;
if ($('#wfacp_mini_cart_start_h').length) {
target = $('#wfacp_mini_cart_start_h');
} else if ($('#order_summary_field').length) {
target = $('#order_summary_field');
} else if ($('.wfacp_order_summary').length) {
target = $('.wfacp_order_summary').first();
} else if ($('.wfacp_mini_cart_start_h').length) {
target = $('.wfacp_mini_cart_start_h').first();
}
if (!target) return;
// Collect non-last-step next buttons from the form
var items = [];
$('.wfacp_main_form .wfacp_page').each(function() {
var page = $(this);
var step = page.data('step');
var isLast = page.hasClass('wfacp_last_page');
var btn = page.find('.wfacp_next_page_button').first();
if (btn.length && !isLast) {
items.push({ step: step, btn: btn });
}
});
if (!items.length) return;
// Read computed styles from original button (still in DOM, fully styled)
var cs = window.getComputedStyle(items[0].btn[0]);
var inlineStyle = 'background:' + cs.background
+ ';color:' + cs.color
+ ';font-size:' + cs.fontSize
+ ';font-weight:' + cs.fontWeight
+ ';font-family:' + cs.fontFamily
+ ';border-radius:' + cs.borderRadius
+ ';padding:' + cs.padding
+ ';min-height:' + cs.minHeight
+ ';border:' + cs.border
+ ';text-transform:' + cs.textTransform
+ ';letter-spacing:' + cs.letterSpacing
+ ';line-height:' + cs.lineHeight
+ ';width:100%;cursor:pointer;display:block'
+ ';box-sizing:border-box;text-align:center';
// Build new buttons with inline styles
var container = $('<div class="wfacp_mc_next_buttons" style="margin-top:15px;"></div>');
items.forEach(function(item, idx) {
var orig = item.btn;
var btn = $('<button type="button"></button>')
.addClass(orig.attr('class'))
.attr('data-next-step', orig.data('next-step'))
.attr('data-current-step', orig.data('current-step'))
.attr('data-text', orig.data('text'))
.html(orig.html())
.attr('style', inlineStyle);
var wrap = $('<div class="wfacp_mc_next_btn" data-for-step="' + item.step + '"></div>');
if (idx > 0) wrap.hide();
wrap.append(btn);
container.append(wrap);
});
target.append(container);
// Now hide the originals
$('.wfacp_main_form .wfacp-next-btn-wrap').css({
'position': 'absolute',
'left': '-9999px',
'visibility': 'hidden',
'pointer-events': 'none'
});
// Step sync function
function sync(stepName, isLast) {
container.find('.wfacp_mc_next_btn').hide();
if (!isLast) {
container.find('.wfacp_mc_next_btn[data-for-step="' + stepName + '"]').show();
}
}
// Primary: FunnelKit step switch event
$(document.body).on('wfacp_step_switching', function(e, obj) {
sync(obj.current_step, obj.last_step);
});
// Fallback: detect from visible page after animation
$(document.body).on('click', '.wfacp_next_page_button, .wfacp_back_page_button', function() {
setTimeout(function() {
var vis = $('.wfacp_page:visible');
if (vis.length) {
sync(vis.data('step'), vis.hasClass('wfacp_last_page'));
}
}, 1000);
});
}
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment