Answers for "add custom data on cart woocommerce"

1

woocommerce add custom field data to cart page

add_filter( "woocommerce_add_cart_item_data", "cs_add_cart_item_data", 10,2 );
function cs_add_cart_item_data( $cart_item, $product_id ){

  /*
  Custom Field name="" attr
  */
  if ( isset($_POST['custom_field_name']) ) {
    $cart_item['custom_field_name'] = sanitize_text_field( $getRawVal );
  }
  return $cart_item;
}
Posted by: Guest on May-08-2021
1

woocommerce add custom field data to cart page

add_filter( "woocommerce_add_cart_item_data", "cs_add_cart_item_data", 10,2 );
function cs_add_cart_item_data( $cart_item, $product_id ){

  /*
  Custom Field name="" attr
  */
  if ( isset($_POST['custom_field_name']) ) {
    $cart_item['custom_field_name'] = sanitize_text_field( $getRawVal );
  }
  return $cart_item;
}
Posted by: Guest on May-08-2021
0

woocommerce show data to cart page

add_filter( "woocommerce_get_item_data", "cs_get_item_data", 10,2 );
function cs_get_item_data( $data, $cart_item ){
  if ( isset( $cart_item['singleFood'] ) ) {
    $data[] = array(
        'name'    => 'Choosen Custom Food Items',
        'value'   => sanitize_text_field( $cart_item['singleFood'] ),
      );
  }
  return $data;
}
Posted by: Guest on May-08-2021
0

woocommerce show data to cart page

add_filter( "woocommerce_get_item_data", "cs_get_item_data", 10,2 );
function cs_get_item_data( $data, $cart_item ){
  if ( isset( $cart_item['singleFood'] ) ) {
    $data[] = array(
        'name'    => 'Choosen Custom Food Items',
        'value'   => sanitize_text_field( $cart_item['singleFood'] ),
      );
  }
  return $data;
}
Posted by: Guest on May-08-2021

Code answers related to "add custom data on cart woocommerce"

Browse Popular Code Answers by Language