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 / Totals.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
Totals.php
59 lines
1 <?php
2
3 namespace Hostinger\Reach\Dto;
4
5 use WC_Order;
6
7 class Totals {
8
9 private float $total;
10 private float $subtotal;
11 private float $tax_total;
12 private float $shipping_total;
13 private float $discount_total;
14 private string $currency;
15
16 public function __construct( float $total, float $subtotal, float $tax_total, float $shipping_total, float $discount_total, string $currency ) {
17 $this->total = $total;
18 $this->subtotal = $subtotal;
19 $this->tax_total = $tax_total;
20 $this->shipping_total = $shipping_total;
21 $this->discount_total = $discount_total;
22 $this->currency = $currency;
23 }
24
25 public function to_array(): array {
26 return array(
27 'total' => $this->total,
28 'subtotal' => $this->subtotal,
29 'tax_total' => $this->tax_total,
30 'shipping_total' => $this->shipping_total,
31 'discount_total' => $this->discount_total,
32 'currency' => $this->currency,
33 );
34 }
35
36 public static function from_order( WC_Order $order ): self {
37 return new self(
38 $order->get_total(),
39 $order->get_subtotal(),
40 $order->get_total_tax(),
41 (float) $order->get_shipping_total(),
42 (float) $order->get_discount_total(),
43 $order->get_currency()
44 );
45 }
46
47
48 public static function from_cart_totals( array $cart_totals, string $currency ): self {
49 return new self(
50 (float) $cart_totals['total'],
51 (float) $cart_totals['subtotal'],
52 (float) $cart_totals['total_tax'],
53 (float) $cart_totals['shipping_total'],
54 (float) $cart_totals['discount_total'],
55 $currency
56 );
57 }
58 }
59