PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Dto / Cart.php
hostinger-reach / src / Dto Last commit date
Cart.php 8 months ago CartItem.php 8 months ago PluginData.php 7 months ago ReachContact.php 7 months ago Totals.php 8 months ago
Cart.php
70 lines
1 <?php
2
3 namespace Hostinger\Reach\Dto;
4
5 class Cart {
6
7 private string $hash;
8 private string $email;
9 private string $currency;
10 private array $items;
11 private array $totals;
12
13 public function __construct( string $hash, string $email, string $currency, array $items, array $totals ) {
14 $this->hash = $hash;
15 $this->email = $email;
16 $this->currency = $currency;
17 $this->items = $items;
18 $this->totals = $totals;
19 }
20
21 public function get_hash(): string {
22 return $this->hash;
23 }
24
25 public function get_currency(): string {
26 return $this->currency;
27 }
28
29 public function get_email(): string {
30 return $this->email;
31 }
32
33 public function get_items(): array {
34 return array_map(
35 function ( $item ) {
36 $cart_item = new CartItem( $item['product_id'], $item['quantity'] );
37
38 return $cart_item->to_array();
39 },
40 $this->items
41 );
42 }
43
44 public function get_totals(): array {
45 $totals = Totals::from_cart_totals( $this->totals, $this->currency );
46
47 return $totals->to_array();
48 }
49
50 public function to_array(): array {
51 return array(
52 'hash' => $this->get_hash(),
53 'currency' => $this->get_currency(),
54 'customer_email' => $this->get_email(),
55 'items' => $this->get_items(),
56 'totals' => $this->get_totals(),
57 );
58 }
59
60 public static function from_array( array $data ): Cart {
61 return new self(
62 $data['hash'],
63 $data['customer_email'],
64 $data['currency'],
65 $data['items'],
66 $data['totals'],
67 );
68 }
69 }
70