Код: Выделить всё
/* Add handling to cart at checkout */
add_action( 'woocommerce_cart_calculate_fees','handling_fee' );
function handling_fee() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
// First test if all products are virtual. Only add fee if at least one product is physical.
$allproductsvirtual = true;
$fee = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values) {
$product = $values['data'];
if( !$product->is_virtual() ){
$allproductsvirtual = false;
}
}
if ( !$allproductsvirtual ) {
$fee = 3.00;
}
$woocommerce->cart->add_fee( 'Handling', $fee, false, 'standard' );
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... al-is-zero