From e94c4954343dffea04b87180a7c68c21bf3cebbd Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Wed, 20 Sep 2023 16:52:09 +0400 Subject: [PATCH] Fix the coding styles --- .../src/Shipment/Shipment.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/ppcp-order-tracking/src/Shipment/Shipment.php b/modules/ppcp-order-tracking/src/Shipment/Shipment.php index ae6ecc5d4..155931d19 100644 --- a/modules/ppcp-order-tracking/src/Shipment/Shipment.php +++ b/modules/ppcp-order-tracking/src/Shipment/Shipment.php @@ -154,23 +154,27 @@ class Shipment implements ShipmentInterface { continue; } - $product = $item->get_product(); + $product = $item->get_product(); + if ( ! is_a( $product, WC_Product::class ) ) { + continue; + } + $currency = $wc_order->get_currency(); $quantity = (int) $item->get_quantity(); $price_without_tax = (float) $wc_order->get_item_subtotal( $item, false ); $price_without_tax_rounded = round( $price_without_tax, 2 ); - $image = wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' ); + $image = wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' ); $ppcp_order_item = new Item( mb_substr( $item->get_name(), 0, 127 ), new Money( $price_without_tax_rounded, $currency ), $quantity, - $product instanceof WC_Product ? $this->prepare_description( $product->get_description() ) : '', + $this->prepare_description( $product->get_description() ), null, - $product instanceof WC_Product ? $product->get_sku() : '', - ( $product instanceof WC_Product && $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS, - $product->get_permalink(), - $image[0] ?? '' + $product->get_sku(), + $product->is_virtual() ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS, + $product->get_permalink(), + $image[0] ?? '' ); $tracking_items[ $item->get_id() ] = $ppcp_order_item->to_array();