diff --git a/src/Product/WCProductAdapter.php b/src/Product/WCProductAdapter.php index 521e395dbe..42717f1222 100644 --- a/src/Product/WCProductAdapter.php +++ b/src/Product/WCProductAdapter.php @@ -572,6 +572,12 @@ protected function map_wc_shipping_weight( string $unit = 'g' ): WCProductAdapte } $weight = wc_get_weight( $this->wc_product->get_weight(), $unit ); + + // Use lb if the unit is lbs, since GMC uses lb. + if ( 'lbs' === $unit ) { + $unit = 'lb'; + } + $this->setShippingWeight( new GoogleProductShippingWeight( [ diff --git a/tests/Unit/Product/WCProductAdapterTest.php b/tests/Unit/Product/WCProductAdapterTest.php index a1e50ceb85..290abb571b 100644 --- a/tests/Unit/Product/WCProductAdapterTest.php +++ b/tests/Unit/Product/WCProductAdapterTest.php @@ -930,6 +930,28 @@ public function test_shipping_dimensions_and_weight_units_use_default_if_wc_opti $this->assertEquals( 1000, $adapted_product->getShippingWeight()->getValue() ); } + public function test_shipping_weight_unit_uses_lb_if_wc_option_is_lbs() { + update_option( 'woocommerce_weight_unit', 'lbs' ); + + $product = WC_Helper_Product::create_simple_product( + false, + [ + 'height' => '3', + 'length' => '4', + 'width' => '5', + 'weight' => '1', + ] + ); + + $adapted_product = new WCProductAdapter( + [ + 'wc_product' => $product, + 'targetCountry' => 'US', + ] + ); + $this->assertEquals( 'lb', $adapted_product->getShippingWeight()->getUnit() ); + } + /** * @param array $shipping_dimensions *