Skip to content

Instantly share code, notes, and snippets.

@ajdinmore
Last active October 5, 2022 19:34
Show Gist options
  • Save ajdinmore/4b89ffc258b33fd8f9a11f087fae9701 to your computer and use it in GitHub Desktop.
Save ajdinmore/4b89ffc258b33fd8f9a11f087fae9701 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
/**
* Plugin Name: WooCommerce Import Fix 2022-10-05
* Description: Fixes importing variable product drafts.
*/
add_filter('woocommerce_product_importer_formatting_callbacks', function (array $callbacks, \WC_Product_Importer $importer) {
$key = array_search('published', $importer->get_mapped_keys());
if (false !== $key && isset($callbacks[$key])){
$original = $callbacks[$key];
$callbacks[$key] = fn($value) => (int)$original($value);
}
return $callbacks;
}, PHP_INT_MAX, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment