Triple echo in filter woocommerce_available_payment_gateways
-
Hi, for some products I need disable “cod” method payment, I use next code:
add_filter( 'woocommerce_available_payment_gateways', 'webmakitra_unset_gateway_by_category' ); function webmakitra_unset_gateway_by_category( $available_gateways ) { //if ( is_admin() ) return $available_gateways; if ( ! is_checkout() ) return $available_gateways; $unset = false; $posted = false; foreach( WC()->cart->get_cart() as $cart_item ) { $onlain_oplata = get_post_meta( $cart_item['product_id'], 'onlain-oplata', true ); if ( $onlain_oplata == 'true' ) { $unset = true; break; } } if ( $unset == true ) { unset( $available_gateways['cod'] ); if($posted != true){ $page = jet_engine()->options_pages->registered_pages['shop-opt']; echo '<div class="inf-onl-opl">' . $page->get( 'pred-info-blok-v-checkuot' ) . '</div>'; $posted = true; } } return $available_gateways; }
All works, but my info (echo) – calling 3 times – https://i.imgur.com/4MlGDbm.png
Why? How fix this?
Thanks
The page I need help with: [log in to see the link]
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Triple echo in filter woocommerce_available_payment_gateways’ is closed to new replies.