Refactor code style

This commit is contained in:
dinamiko 2022-03-17 16:45:57 +01:00
parent ec22aad35b
commit ccb528ba2a

View file

@ -124,22 +124,16 @@ class ItemFactory {
* @return Item
*/
private function from_wc_order_line_item( \WC_Order_Item_Product $item, \WC_Order $order ): Item {
$currency = $order->get_currency();
$product = $item->get_product();
$shipping_tax = round( (float) $order->get_shipping_tax(), 2 );
/**
* The WooCommerce product.
*
* @var \WC_Product $product
*/
$quantity = (int) $item->get_quantity();
$currency = $order->get_currency();
$product = $item->get_product();
$shipping_tax = round( (float) $order->get_shipping_tax(), 2 );
$quantity = (int) $item->get_quantity();
$price = (float) $order->get_item_subtotal( $item, true );
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
$price_without_tax_rounded = round( $price_without_tax, 2 );
$tax = round( $price - $price_without_tax_rounded, 2 );
$tax = new Money( $tax + $shipping_tax, $currency );
return new Item(
mb_substr( $product->get_name(), 0, 127 ),
new Money( $price_without_tax_rounded, $currency ),