Skip to content

Commit bb26c55

Browse files
gatispelcersbriedis
authored andcommitted
Added new fields to OrderCostsItem. Fixed OrderCostsGroup. (#20)
1 parent 394d788 commit bb26c55

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

src/Structures/Order/OrderCostGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function fromArray(array $raw)
1919
$orderCosts = new self;
2020

2121
$orderCosts->printfulCosts = !empty($raw['costs']) ? OrderCostsItem::fromArray($raw['costs']) : null;
22-
$orderCosts->printfulCosts = !empty($raw['retail_costs']) ? OrderCostsItem::fromArray($raw['retail_costs']) : null;
22+
$orderCosts->retailCosts = !empty($raw['retail_costs']) ? OrderCostsItem::fromArray($raw['retail_costs']) : null;
2323

2424
return $orderCosts;
2525
}

src/Structures/Order/OrderCostsItem.php

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,53 @@ class OrderCostsItem extends BaseItem
88
{
99

1010
/**
11-
* @var string
11+
* @var float
1212
* Total cost of all items
1313
*/
1414
public $subtotal;
1515

1616
/**
17-
* @var string
17+
* @var float
1818
* Discount sum
1919
*/
2020
public $discount;
2121

2222
/**
23-
* @var string
23+
* @var float
2424
* Shipping costs
2525
*/
2626
public $shipping;
2727

2828
/**
29-
* @var string
29+
* @var float
3030
* Sum of taxes (not included in the item price)
3131
*/
3232
public $tax;
3333

3434
/**
35-
* @var string
35+
* @var float
3636
* Sum of taxes (not included in the item price)
3737
*/
3838
public $total;
3939

40+
/**
41+
* @var string
42+
* 3 letter currency code
43+
*/
44+
public $currency;
45+
46+
/**
47+
* @var float
48+
* Digitization costs
49+
*/
50+
public $digitization;
51+
52+
/**
53+
* @var float
54+
* Sum of vat (not included in the item price)
55+
*/
56+
public $vat;
57+
4058
/**
4159
* @param array $raw
4260
* @return OrderCostsItem
@@ -45,11 +63,14 @@ public static function fromArray(array $raw)
4563
{
4664
$costs = new self;
4765

48-
$costs->subtotal = $raw['subtotal'] ? (float)$raw['subtotal'] : null;
49-
$costs->discount = $raw['discount'] ? (float)$raw['discount'] : null;
50-
$costs->shipping = $raw['shipping'] ? (float)$raw['shipping'] : null;
51-
$costs->tax = $raw['tax'] ? (float)$raw['tax'] : null;
52-
$costs->total = $raw['total'] ? (float)$raw['total'] : null;
66+
$costs->subtotal = isset($raw['subtotal']) ? (float)$raw['subtotal'] : null;
67+
$costs->discount = isset($raw['discount']) ? (float)$raw['discount'] : null;
68+
$costs->shipping = isset($raw['shipping']) ? (float)$raw['shipping'] : null;
69+
$costs->tax = isset($raw['tax']) ? (float)$raw['tax'] : null;
70+
$costs->total = isset($raw['total']) ? (float)$raw['total'] : null;
71+
$costs->currency = isset($raw['currency']) ? $raw['currency'] : null;
72+
$costs->digitization = isset($raw['digitization']) ? (float)$raw['digitization'] : null;
73+
$costs->vat = isset($raw['vat']) ? (float)$raw['vat'] : null;
5374

5475
return $costs;
5576
}
@@ -65,6 +86,9 @@ public function toArray()
6586
'tax' => $this->tax,
6687
'subtotal' => $this->subtotal,
6788
'total' => $this->total,
89+
'currency' => $this->currency,
90+
'digitization' => $this->digitization,
91+
'vat' => $this->vat,
6892
];
6993
}
7094
}

0 commit comments

Comments
 (0)