| @@ -1,17 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | +defined( 'ABSPATH' ) || exit; | |
| 2 | 3 | |
| 3 | -defined( 'ABSPATH' ) || exit; | |
| 4 | +/** | |
| 5 | + * @var object $order | |
| 6 | + * @var array $currency_settings | |
| 7 | + * @var bool $hasSubscription | |
| 8 | + */ | |
| 4 | 9 | |
| 5 | 10 | if (!$order->items) { |
| 6 | 11 | return ''; |
| 7 | 12 | } |
| 8 | -$currencySign = \FluentBooking\App\Services\CurrenciesHelper::getGlobalCurrencySign(); | |
| 9 | 13 | |
| 10 | -$currencySetting = [ | |
| 11 | - 'currency_sign' => $currencySign, | |
| 12 | -]; | |
| 13 | - | |
| 14 | 14 | ?> |
| 15 | 15 | <table class="table fluent_booking_order_items_table fluent_booking_table table_bordered"> |
| 16 | 16 | <thead> |
| 17 | 17 | <th><?php esc_html_e('Item', 'fluent-booking'); ?></th> |
| @@ -19,31 +19,31 @@ | ||
| 19 | 19 | <th><?php esc_html_e('Price', 'fluent-booking'); ?></th> |
| 20 | 20 | <th><?php esc_html_e('Line Total', 'fluent-booking'); ?></th> |
| 21 | 21 | </thead> |
| 22 | 22 | <tbody> |
| 23 | - <?php $subTotal = 0; ?> | |
| 24 | - <?php foreach ($order->items->toArray() as $order_item) { | |
| 25 | - if (is_array($order_item)) { | |
| 26 | - if ($order_item['item_total']) :?> | |
| 23 | + <?php $fluentBookingSubTotal = 0; ?> | |
| 24 | + <?php foreach ($order->items->toArray() as $fluentBookingOrderItem) { | |
| 25 | + if (is_array($fluentBookingOrderItem)) { | |
| 26 | + if (!empty($fluentBookingOrderItem['item_total'])) :?> | |
| 27 | 27 | <tr> |
| 28 | - <td><?php echo esc_html($order_item['item_name']); ?></td> | |
| 29 | - <td><?php echo esc_html($order_item['quantity']); ?></td> | |
| 30 | - <td><?php echo esc_attr(fluentbookingFormattedAmount($order_item['item_price'], $currencySetting)); ?></td> | |
| 31 | - <td><?php echo esc_attr(fluentbookingFormattedAmount($order_item['item_total'], $currencySetting)); ?></td> | |
| 28 | + <td><?php echo esc_html($fluentBookingOrderItem['item_name']); ?></td> | |
| 29 | + <td><?php echo esc_html($fluentBookingOrderItem['quantity']); ?></td> | |
| 30 | + <td><?php echo esc_attr(fluentbookingFormattedAmount($fluentBookingOrderItem['item_price'], $currency_settings)); ?></td> | |
| 31 | + <td><?php echo esc_attr(fluentbookingFormattedAmount($fluentBookingOrderItem['item_total'], $currency_settings)); ?></td> | |
| 32 | 32 | </tr> |
| 33 | 33 | <?php |
| 34 | - $subTotal += $order_item['item_total']; | |
| 34 | + $fluentBookingSubTotal += $fluentBookingOrderItem['item_total']; | |
| 35 | 35 | endif; |
| 36 | 36 | } else { |
| 37 | - if ($order_item->item_total) :?> | |
| 37 | + if (isset($fluentBookingOrderItem->item_total) && $fluentBookingOrderItem->item_total) :?> | |
| 38 | 38 | <tr> |
| 39 | - <td><?php echo esc_html($order_item->item_name); ?></td> | |
| 40 | - <td><?php echo esc_html($order_item->quantity); ?></td> | |
| 41 | - <td><?php echo esc_html(fluentbookingFormattedAmount($order_item->item_price, $currencySetting)); ?></td> | |
| 42 | - <td><?php echo esc_html(fluentbookingFormattedAmount($order_item->item_total, $currencySetting)); ?></td> | |
| 39 | + <td><?php echo esc_html($fluentBookingOrderItem->item_name); ?></td> | |
| 40 | + <td><?php echo esc_html($fluentBookingOrderItem->quantity); ?></td> | |
| 41 | + <td><?php echo esc_html(fluentbookingFormattedAmount($fluentBookingOrderItem->item_price, $currency_settings)); ?></td> | |
| 42 | + <td><?php echo esc_html(fluentbookingFormattedAmount($fluentBookingOrderItem->item_total, $currency_settings)); ?></td> | |
| 43 | 43 | </tr> |
| 44 | 44 | <?php |
| 45 | - $subTotal += $order_item->item_total; | |
| 45 | + $fluentBookingSubTotal += $fluentBookingOrderItem->item_total; | |
| 46 | 46 | endif; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | }; |
| @@ -49,22 +49,22 @@ | ||
| 49 | 49 | }; |
| 50 | 50 | ?> |
| 51 | 51 | </tbody> |
| 52 | 52 | <tfoot> |
| 53 | - <?php $discountTotal = 0; | |
| 54 | - if (isset($order->discounts['applied']) && count($order->discounts['applied'])) : ?> | |
| 53 | + <?php $fluentBookingDiscountTotal = 0; | |
| 54 | + if (isset($order->discounts) && count($order->discounts)) : ?> | |
| 55 | 55 | <tr class="fluent_booking_total_row"> |
| 56 | 56 | <th style="text-align: right" colspan="3"><?php esc_html_e('Sub-Total', 'fluent-booking'); ?></th> |
| 57 | - <td><?php echo esc_html(fluentbookingFormattedAmount($subTotal, $currencySetting)); ?></td> | |
| 57 | + <td><?php echo esc_html(fluentbookingFormattedAmount($fluentBookingSubTotal, $currency_settings)); ?></td> | |
| 58 | 58 | </tr> |
| 59 | 59 | <?php |
| 60 | - foreach ($order->discounts['applied'] as $discount) : | |
| 61 | - $discountTotal += $discount->item_total; | |
| 60 | + foreach ($order->discounts as $fluentBookingDiscount) : | |
| 61 | + $fluentBookingDiscountTotal += $fluentBookingDiscount->item_total; | |
| 62 | 62 | ?> |
| 63 | 63 | <tr class="fluent_booking_discount_row"> |
| 64 | - <th style="text-align: right" | |
| 65 | - colspan="3"><?php echo 'Discounts (' . esc_html($discount->item_name) . ' )'; ?></th> | |
| 66 | - <td><?php echo '-' . esc_html(fluentbookingFormattedAmount($discount->item_total, $currencySetting)); ?></td> | |
| 64 | + <?php /* translators: %s: Discount name */ ?> | |
| 65 | + <th style="text-align: right" colspan="3"><?php printf(esc_html__('Discounts(%s)', 'fluent-booking'), esc_html($fluentBookingDiscount->item_name)); ?></th> | |
| 66 | + <td><?php echo '-' . esc_html(fluentbookingFormattedAmount($fluentBookingDiscount->item_total, $currency_settings)); ?></td> | |
| 67 | 67 | </tr> |
| 68 | 68 | <?php endforeach; ?> |
| 69 | 69 | <?php endif; ?> |
| 70 | 70 | <tr class="fluent_booking_total_payment_row"> |
| @@ -70,11 +70,11 @@ | ||
| 70 | 70 | <tr class="fluent_booking_total_payment_row"> |
| 71 | 71 | <th style="text-align: right" colspan="3"><?php esc_html_e('Total', 'fluent-booking'); ?></th> |
| 72 | 72 | <td> |
| 73 | 73 | <?php if (isset($hasSubscription) && $hasSubscription) : ?> |
| 74 | - <?php echo esc_attr(fluentbookingFormattedAmount($order->total_amount, $currencySetting)); ?> | |
| 74 | + <?php echo esc_attr(fluentbookingFormattedAmount($order->total_amount, $currency_settings)); ?> | |
| 75 | 75 | <?php else: ?> |
| 76 | - <?php echo esc_attr(fluentbookingFormattedAmount($order->total_amount - $discountTotal, $currencySetting)); ?> | |
| 76 | + <?php echo esc_attr(fluentbookingFormattedAmount($order->total_amount, $currency_settings)); ?> | |
| 77 | 77 | <?php endif; ?> |
| 78 | 78 | </td> |
| 79 | 79 | </tr> |
| 80 | 80 | </tfoot> |