Save custom input field value into cart item code example
Example: Save custom input field value into cart item
// 3,5. Add fee ;)
add_action( 'woocommerce_cart_calculate_fees', 'bbloomer_add_checkout_fee' );
function bbloomer_add_checkout_fee() {
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
if (!empty( $cart_item['custom_text_add_on'] ) ) {
WC()->cart->add_fee( 'Product Add-on fee', 55 );
break;
}
}
}