PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / Views / ViewFrontend.php

ViewFrontend.php in Packeta 2.1, at src/Packetery/Module/Views/ViewFrontend.php

78 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare( strict_types=1 );
4
5 namespace Packetery\Module\Views;
6
7 use Packetery\Latte\Engine;
8 use Packetery\Module\Framework\WpAdapter;
9 use Packetery\Module\Order\DetailCommonLogic;
10 use Packetery\Module\Order\Repository;
11 use WC_Order;
12
13 class ViewFrontend {
14
15 /**
16 * @var Repository
17 */
18 private $orderRepository;
19
20 /**
21 * @var Engine
22 */
23 private $latteEngine;
24
25 /**
26 * @var DetailCommonLogic
27 */
28 private $detailCommonLogic;
29
30 /**
31 * @var WpAdapter
32 */
33 private $wpAdapter;
34
35 public function __construct(
36 Repository $orderRepository,
37 Engine $latteEngine,
38 DetailCommonLogic $detailCommonLogic,
39 WpAdapter $wpAdapter
40 ) {
41 $this->orderRepository = $orderRepository;
42 $this->latteEngine = $latteEngine;
43 $this->detailCommonLogic = $detailCommonLogic;
44 $this->wpAdapter = $wpAdapter;
45 }
46
47 /**
48 * Renders delivery detail for packetery orders, on "thank you" page and in frontend detail.
49 *
50 * @param WC_Order $wcOrder WordPress order.
51 */
52 public function renderOrderDetail( WC_Order $wcOrder ): void {
53 $order = $this->orderRepository->getByWcOrderWithValidCarrier( $wcOrder );
54 if ( $order === null ) {
55 return;
56 }
57
58 if ( $this->detailCommonLogic->shouldHidePacketaInfo( $order ) ) {
59 return;
60 }
61
62 $this->latteEngine->render(
63 PACKETERY_PLUGIN_DIR . '/template/order/detail.latte',
64 [
65 'displayPickupPointInfo' => $this->detailCommonLogic->shouldDisplayPickupPointInfo(),
66 'order' => $order,
67 'translations' => [
68 'packeta' => $this->wpAdapter->__( 'Packeta', 'packeta' ),
69 'pickupPointName' => $this->wpAdapter->__( 'Pickup Point Name', 'packeta' ),
70 'pickupPointDetail' => $this->wpAdapter->__( 'Pickup Point Detail', 'packeta' ),
71 'address' => $this->wpAdapter->__( 'Address', 'packeta' ),
72 'packetTrackingOnline' => $this->wpAdapter->__( 'Packet tracking online', 'packeta' ),
73 ],
74 ]
75 );
76 }
77 }
78