An open API service indexing awesome lists of open source software.

https://github.com/wpup/wc-export

Export various data from WooCommerce
https://github.com/wpup/wc-export

Last synced: 11 months ago
JSON representation

Export various data from WooCommerce

Awesome Lists containing this project

README

          

# WooCommerce Export

[![Build Status](https://travis-ci.org/wpup/wc-export.svg?branch=master)](https://travis-ci.org/wpup/wc-export)
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)

Export various data from WooCommerce.

The plugin cames with two exporters, a customers export that will export all billing fields and a emails exporter that will export the billing email field from a order.

The are three writers built in, CSV, XML and JSON.

## Installation

```sh
composer require frozzare/wc-export
```

## Documentation

* [Custom export](#custom-export)
* [Custom writer](#custom-writer)

### Custom export

Example of a custom export type that will export the `billing_email` field from a order. With `query_args` method you can modify the `WP_Query` arguments.

```php
__( 'Email', 'woocommerce' )
];
}

/**
* Modify WP Query args.
*
* @param array $args
*
* @return array
*/
public function query_args( array $args ) {
return $args;
}
}
```

Then you have to add the custom export to the exporter list with `wc_export_classes` filter.

```php
'\\Custom_Emails'
] );
} );
```

### Custom writer

Example of a custom export writer that will export the given data argument to `render` method as JSON.

```php
$row ) {
if ( ! is_array( $row ) ) {
unset( $data[$index] );
}
}

echo json_encode( $data, JSON_UNESCAPED_UNICODE );
}
}
```

Then you have to add the custom writer to the writers list with `wc_export_writers` filter.

```php
'\\Custom_JSON'
] );
} );
```

## License

MIT © [Fredrik Forsmo](https://github.com/frozzare)