You are here

function _webform_csv_data_productfield in Commerce Webform 7.2

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

Implements _webform_csv_data_component().

File

./productfield.inc, line 674

Code

function _webform_csv_data_productfield($component, $export_options, $values) {
  $values = is_array($values) ? $values : array();
  $return = array();
  $products = _productfield_products($component);
  foreach ($values as $id => $value) {
    $values[$id] = json_decode($value);
  }
  foreach ($products as $product_id => $product) {
    $index = FALSE;
    foreach ($values as $value) {
      if ($value->product_id == $product_id) {
        $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;
}