You are here

function _webform_csv_data_productfield in Commerce Webform 8

Same name and namespace in other branches
  1. 7.2 productfield.inc \_webform_csv_data_productfield()
  2. 7 productfield.inc \_webform_csv_data_productfield()

Implements _webform_csv_data_component().

File

./productfield.inc, line 584

Code

function _webform_csv_data_productfield($component, $export_options, $values) {
  $options = $component['extra']['items'];
  foreach ($values as $id => $value) {
    $values[$id] = json_decode($value);
  }
  $return = array();
  foreach ($options as $key => $item) {
    $index = FALSE;
    foreach ($values as $value) {
      if ($value->product_id == $key) {
        $index = $value;
      }
    }
    if ($index !== FALSE) {
      if (!empty($index->paid)) {
        $return[] = $index->quantity;
        $return[] = '0';
      }
      else {
        $return[] = '0';
        $return[] = $index->quantity;
      }
    }
    else {
      $return[] = '0';
      $return[] = '0';
    }
  }
  return $return;
}