Skip to content

Commit

Permalink
Merge pull request #439 from woocommerce/fix/219-bundle-price
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed Jun 19, 2024
2 parents cf11652 + 7860b3c commit e13e368
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion assets/js/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const getProductFieldObject = ( product, quantity ) => {
...getProductCategories( product ),
quantity: product.quantity ?? quantity,
price: formatPrice(
product.prices.price,
// Use line total for bundled products, if available.
product.totals?.line_total || product.prices.price,
product.prices.currency_minor_unit
),
...variantData,
Expand Down
7 changes: 7 additions & 0 deletions includes/class-wc-abstract-google-analytics-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ public function get_formatted_product( WC_Product $product, $variation_id = 0, $
}
}

// Integration with Product Bundles.
// Get the minimum price, as `get_price` may return 0 if the product is a bundle and the price is potentially a range.
// Even a range containing a single value.
if ( $product->is_type( 'bundle' ) && is_callable( [ $product, 'get_bundle_price' ] ) ) {
$price = $product->get_bundle_price( 'min' );
}

$formatted = array(
'id' => $product_id,
'name' => $product->get_title(),
Expand Down

0 comments on commit e13e368

Please sign in to comment.