add_action wp creates endless loop in checkout
-
Hi, add_action wp creates endless loop in checkout :/
the code I have that causes it is:
function my_custom_wc_free_shipping_notice() {
/*if ( ! is_cart() && ! is_checkout() ) { // Remove partial if you don’t want to show it on cart/checkout
return;
}*/if(is_admin()) {
return;
}wc_clear_notices();
$packages = WC()->cart->get_shipping_packages();
$package = reset( $packages );
$zone = wc_get_shipping_zone( $package );$cart_total = WC()->cart->get_displayed_subtotal();
if ( WC()->cart->display_prices_including_tax() ) {
$cart_total = round( $cart_total – ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
} else {
$cart_total = round( $cart_total – WC()->cart->get_discount_total(), wc_get_price_decimals() );
}
foreach ( $zone->get_shipping_methods( true ) as $k => $method ) {
$min_amount = $method->get_option( ‘min_amount’ );
/*echo ‘$min_amount: ‘.$min_amount;
echo ‘ $method->id: ‘. $method->id;*/if ( $method->id == ‘free_shipping’ && ! empty( $min_amount ) && $cart_total < $min_amount ) {
$remaining = $min_amount – $cart_total;wc_add_notice( sprintf( ‘Adiciona mais %1$s de produtos para <b>PORTES GRÁTIS<b/>! Continuar a Comprar‘, wc_price( $remaining ), wc_get_page_permalink( ‘shop’ ) ) );
//wc_print_notice( sprintf( ‘Adiciona mais %1$s de produtos para <b>PORTES GRÁTIS<b/>! Continuar a Comprar‘, wc_price( $remaining ), wc_get_page_permalink( ‘shop’ ) ) );}
//remove_action( ‘wp’, ‘my_custom_wc_free_shipping_notice’);
}}
add_action( ‘wp’, ‘my_custom_wc_free_shipping_notice’);The code snipet is currently disabled.
Thanks,
Cláudio FreireThe page I need help with: [log in to see the link]
- The topic ‘add_action wp creates endless loop in checkout’ is closed to new replies.