Skip to content

Instantly share code, notes, and snippets.

@DavidAnderson684
DavidAnderson684 / vat-compliance-csv-alterations-feb2023.php
Last active May 29, 2023 21:47
WooCommerce VAT compliance CSV download alterations
<?php
// See: https://www.simbahosting.co.uk/s3/faqs/when-downloading-a-detailed-csv-how-can-i-add-an-extra-column/
// Set the list of desired columns for the spreadsheet
add_filter('wc_eu_vat_compliance_csv_header_columns', function() {
$desired_columns = [
'Order number',
'Date (local)',
@DavidAnderson684
DavidAnderson684 / mu-plugins-eu-vat-modifications.php
Created July 23, 2020 21:57
Add columns to spreadsheet download
<?php
if (!defined('ABSPATH')) die('No direct access.');
add_filter('wc_eu_vat_certify_message', function($msg) { return 'For the correct carrying out of VAT auditing regulations, please confirm your country of residence:'; });
// Below: adding columns to the spreadsheet
// Make sure that the order meta field 'PayPal Transaction Fee' is fetched from the database when selecting data for the report.
add_filter('wc_eu_vat_compliance_report_meta_fields', 'my_wc_eu_vat_compliance_report_meta_fields', 10, 2);
<?php
// Install as an mu-plugin, and use something like WP-Crontrol to add a regular repeating call of the purge_vfb_data action
if (!defined('ABSPATH')) die('No direct access');
add_action('purge_vfb_data', 'my_purge_vfb_data', 10, 1);
function my_purge_vfb_data($days = 90) {
global $wpdb;
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_type='vfb_entry' AND post_date < DATE_SUB(NOW(), INTERVAL %d DAY);", $days));