get_product(); $product_b = $b->get_product(); if ( is_object( $product_a ) && is_object( $product_b ) ) { $type_a = $product_a->get_type(); $type_b = $product_b->get_type(); // Move 'car_option' to the end if ( 'car_option' === $type_a && 'car_option' !== $type_b ) { return 1; } elseif ( 'car_option' !== $type_a && 'car_option' === $type_b ) { return -1; } } return 0; } } $items = array_values( $items ); usort( $items, 'sort_items_by_car_option' ); foreach ( $items as $item_id => $item ) : $product = $item->get_product(); $sku = ''; $purchase_note = ''; $image = ''; if ( ! apply_filters( 'woocommerce_order_item_visible', true, $item ) ) { continue; } if ( is_object( $product ) ) { $sku = $product->get_sku(); $purchase_note = $product->get_purchase_note(); $image = $product->get_image( $image_size ); $product_type = $product->get_type(); } //additional data for order info in rental if ( apply_filters( 'stm_is_rental', false ) && function_exists( 'stm_get_rental_order_fields_values' ) ) { $cart_items = stm_get_cart_items(); $product_id = ( 'variation' === $product_type ) ? $cart_items['car_class']['id'] : $product->get_id(); $car_options = $cart_items['options']; $order_days = $cart_items['car_class']['days']; $order_hours = isset( $cart_items['car_class']['hours'] ) ? $cart_items['car_class']['hours'] : 0; $car_price = $cart_items['car_class']['price']; $order_total = ''; $fixedPrice = ( class_exists( 'PriceForQuantityDays' ) ) ? PriceForQuantityDays::getFixedPrice( $product_id ) : null; $priceDate = PriceForDatePeriod::getDescribeTotalByDays( $car_price, $product_id ); $priceDateSimpleDays = count( $priceDate['simple_price'] ); $priceDateSimplePrice = $priceDate['simple_price'][0]; $priceDateTotal = array_sum( $priceDate['promo_price'] ); $pricePerHour = floatval( get_post_meta( $product_id, 'rental_price_per_hour_info', true ) ); $pricePerHourTotal = $pricePerHour * $order_hours; $discount = ( class_exists( 'DiscountByDays' ) ) ? DiscountByDays::get_days_post_meta( $product_id ) : null; $fields = stm_get_rental_order_fields_values(); $location_fee = 0; if ( 'car_option' !== $product_type ) { if ( ! empty( $fixedPrice ) ) { $order_total = $fixedPrice * $priceDateSimpleDays; } else { $order_total = $priceDateSimpleDays * $priceDateSimplePrice; } if ( ! empty( $priceDate ) && count( $priceDate['promo_price'] ) > 0 ) { $order_total += $priceDateTotal; } if ( ! empty( $pricePerHour ) ) { $order_total += $pricePerHourTotal; } } if ( 'on' === $fields['return_same'] && apply_filters( 'stm_me_get_nuxy_mod', true, 'enable_fee_for_same_location' ) && ! empty( $fields['pickup_location_fee'] ) ) { $location_fee = $fields['pickup_location_fee']; } elseif ( 'off' === $fields['return_same'] && ! empty( $fields['return_location_fee'] ) ) { $location_fee = $fields['return_location_fee']; } } ?>