Skip to content

Instantly share code, notes, and snippets.

@jbrinley
Last active August 19, 2019 14:42
Show Gist options
  • Save jbrinley/9101f1e350c236e4e3c18568cf8dea8f to your computer and use it in GitHub Desktop.
Save jbrinley/9101f1e350c236e4e3c18568cf8dea8f to your computer and use it in GitHub Desktop.
Convert BigCommerce category IDs to WordPress category IDs
<?php
function bc_cats_to_wp_cats( $category_ids ) {
$query = new \WP_Term_Query();
return $query->query( [
'taxonomy' => \BigCommerce\Taxonomies\Product_Category\Product_Category::NAME,
'meta_query' => [
[
'key' => 'bigcommerce_id',
'value' => $category_ids,
'compare' => 'IN',
],
],
'hide_empty' => false,
'fields' => 'ids'
] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment