save custom input field value into cart item

Solutions on MaxInterview for save custom input field value into cart item by the best coders in the world

showing results for - "save custom input field value into cart item"
Cristóbal
27 Jun 2017
1// 3,5. Add fee ;)
2 
3add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_add_checkout_fee' );
4   
5function bbloomer_add_checkout_fee() {
6   foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
7        if (!empty( $cart_item['custom_text_add_on'] ) ) {
8           WC()->cart->add_fee( 'Product Add-on fee', 55 );
9            break;
10        }
11    }
12}
13