woocommerce add custom field data to cart page

Solutions on MaxInterview for woocommerce add custom field data to cart page by the best coders in the world

showing results for - "woocommerce add custom field data to cart page"
Kate
14 May 2016
1add_filter( "woocommerce_add_cart_item_data", "cs_add_cart_item_data", 10,2 );
2function cs_add_cart_item_data( $cart_item, $product_id ){
3
4  /*
5  Custom Field name="" attr
6  */
7  if ( isset($_POST['custom_field_name']) ) {
8    $cart_item['custom_field_name'] = sanitize_text_field( $getRawVal );
9  }
10  return $cart_item;
11}