Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xlplugins/b80a319662aac2c3acb687c14dbede4d to your computer and use it in GitHub Desktop.
Save xlplugins/b80a319662aac2c3acb687c14dbede4d to your computer and use it in GitHub Desktop.
force payment method fragments in update order review ajax
add_filter( 'woocommerce_update_order_review_fragments', function ( $fragments ) {
if ( isset( $fragments['.woocommerce-checkout-payment'] ) && empty( $fragments['.woocommerce-checkout-payment'] ) ) {
ob_start();
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
WC()->payment_gateways()->set_current_gateway( $available_gateways );
} else {
$available_gateways = array();
}
$checkout = WC()->checkout();
$order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
include WFACP_TEMPLATE_COMMON . '/checkout/payment.php';
$html = ob_get_clean();
if ( ! empty( $html ) ) {
$fragments['.woocommerce-checkout-payment'] = $html;
} else {
unset( $fragments['.woocommerce-checkout-payment'] );
}
}
return $fragments;
}, PHP_INT_MAX );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment