DEV Community 👩‍💻👨‍💻

BhanuSingh
BhanuSingh

Posted on

WooCommerce Default Import & Export : How to return error when using woocommerce_product_import_pre_insert_product_object

I am adding support to import custom taxonomy in a WooCommerce store.

function process_import( $object, $data ) {
  if (is_a($object, 'WC_Product')) {
    if (!empty($data['color_tax'])) {
      $object->save();
      $set_taxonomy = process_taxonomy_save($object, $data['color_tax'], 'color');
     // How to handle an error so that it gets logged
    }
  }
  return $object;
}
add_filter( 'woocommerce_product_import_pre_insert_product_object', __NAMESPACE__.'\\process_import',

Top comments (0)

We are hiring! Do you want to be our Senior Platform Engineer? Are you capable of chipping in across sysadmin, ops, and site reliability work, while supporting the open source stack that runs DEV and other communities?

This role might just be for you!

Apply now