Skip to content

Commit

Permalink
Reduce categories data to name only
Browse files Browse the repository at this point in the history
  • Loading branch information
Martyn Jones committed Dec 7, 2023
1 parent d114b28 commit d7d9add
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion includes/class-wc-abstract-google-analytics-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public function get_formatted_product( WC_Product $product ): array {
return array(
'id' => $this->get_product_identifier( $product ),
'name' => $product->get_name(),
'categories' => wc_get_product_terms( $product->get_id(), 'product_cat', array( 'number' => 5 ) ),
'categories' => array_map(
fn( $category ) => array( 'name' => $category->name ),
wc_get_product_terms( $product->get_id(), 'product_cat', array( 'number' => 5 ) )
),
'prices' => array(
'price' => $product->get_price(),
'currency_minor_unit' => wc_get_price_decimals(),
Expand Down

0 comments on commit d7d9add

Please sign in to comment.