|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helix\Shopify; |
|
4
|
|
|
|
|
5
|
|
|
use Helix\Shopify\AbandonedCheckout\Discount; |
|
6
|
|
|
use Helix\Shopify\Base\Data; |
|
7
|
|
|
use Helix\Shopify\Order\Address; |
|
8
|
|
|
use Helix\Shopify\Order\OrderItem; |
|
9
|
|
|
use Helix\Shopify\Order\Shipping; |
|
10
|
|
|
use Helix\Shopify\Order\Tax; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* An abandoned checkout. |
|
14
|
|
|
* |
|
15
|
|
|
* @see https://shopify.dev/docs/admin-api/rest/reference/orders/abandoned-checkouts |
|
16
|
|
|
* |
|
17
|
|
|
* @method string getAbandonedCheckoutUrl () |
|
18
|
|
|
* @method Address getBillingAddress () |
|
19
|
|
|
* @method bool getBuyerAcceptsMarketing() |
|
20
|
|
|
* @method string getCartToken () |
|
21
|
|
|
* @method string getClosedAt () |
|
22
|
|
|
* @method string getCreatedAt () |
|
23
|
|
|
* @method string getCurrency () |
|
24
|
|
|
* @method Customer getCustomer () |
|
25
|
|
|
* @method string getCustomerLocale () |
|
26
|
|
|
* @method int getDeviceId () |
|
27
|
|
|
* @method string getEmail () |
|
28
|
|
|
* @method string getLandingSite () |
|
29
|
|
|
* @method OrderItem[] getLineItems () |
|
30
|
|
|
* @method int getLocationId () |
|
31
|
|
|
* @method string getNote () |
|
32
|
|
|
* @method string getPhone () |
|
33
|
|
|
* @method string getPresentmentCurrency () |
|
34
|
|
|
* @method string getReferringSite () |
|
35
|
|
|
* @method Address getShippingAddress () |
|
36
|
|
|
* @method Shipping[] getShippingLines () |
|
37
|
|
|
* @method string getSourceName () |
|
38
|
|
|
* @method string getSubtotalPrice () |
|
39
|
|
|
* @method Tax[] getTaxLines () |
|
40
|
|
|
* @method bool hasTaxesIncluded () |
|
41
|
|
|
* @method string getToken () |
|
42
|
|
|
* @method string getTotalDiscounts () |
|
43
|
|
|
* @method string getTotalLineItemsPrice () |
|
44
|
|
|
* @method string getTotalPrice () |
|
45
|
|
|
* @method string getTotalTax () |
|
46
|
|
|
* @method number getTotalWeight () |
|
47
|
|
|
* @method string getUpdatedAt () |
|
48
|
|
|
* @method string getUserId () |
|
49
|
|
|
*/ |
|
50
|
|
|
class AbandonedCheckout extends Data |
|
51
|
|
|
{ |
|
52
|
|
|
|
|
53
|
|
|
const SEARCH_STATUS_CLOSED = 'closed'; |
|
54
|
|
|
const SEARCH_STATUS_OPEN = 'open'; |
|
55
|
|
|
|
|
56
|
|
|
const MAP = [ |
|
57
|
|
|
'billing_address' => Address::class, |
|
58
|
|
|
'customer' => Customer::class, |
|
59
|
|
|
'line_items' => [OrderItem::class], |
|
60
|
|
|
'shipping_address' => Address::class, |
|
61
|
|
|
'shipping_lines' => Shipping::class, |
|
62
|
|
|
'tax_lines' => [Tax::class] |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
protected function _setData(array $data) |
|
66
|
|
|
{ |
|
67
|
|
|
// abandoned checkouts aren't entities. |
|
68
|
|
|
unset($data['id']); |
|
69
|
|
|
|
|
70
|
|
|
// always null |
|
71
|
|
|
unset($data['completed_at'], $data['gateway']); |
|
72
|
|
|
|
|
73
|
|
|
return parent::_setData($data); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return Discount[] |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getDiscountCodes() |
|
80
|
|
|
{ |
|
81
|
|
|
// the discounts are in an extra dimension for some reason. |
|
82
|
|
|
$discounts = array_column($this->data['discount_codes'], 'discount_code'); |
|
83
|
|
|
return $this->api->factoryAll($this, Discount::class, $discounts); |
|
84
|
|
|
} |
|
85
|
|
|
} |