Answers for "Save custom input field value into cart item"

PHP
0

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;
        }
    }
}
Posted by: Guest on May-08-2021

Code answers related to "Save custom input field value into cart item"

Browse Popular Code Answers by Language