OrderService

This service class contains function related to orders.
All public functions are available in the Twig template renderer.

Namespace

IO\Services

Constants
Type Name Value Description

array

WRAPPED_ORDERITEM_TYPES

[1,2,3,9,13]

array

VISIBLE_ORDER_TYPES

[1,5]

Properties
Type Name Description

OrderRepositoryContract

$orderRepository

BasketService

$basketService

SessionStorageRepositoryContract

$sessionStorageRepository

FrontendPaymentMethodRepositoryContract

$frontendPaymentMethodRepository

AddressRepositoryContract

$addressRepository

UrlService

$urlService

CheckoutService

$checkoutService

CustomerService

$customerService

ContactRepositoryContract

$contactRepository

GiftCardRepositoryContract

$giftCardRepository

string

$pluginNamespace

Methods
public __construct($orderRepository, $basketService, $sessionStorageRepository, $frontendPaymentMethodRepository, $addressRepository, $urlService, $checkoutService, $customerService, $contactRepository, $giftCardRepository)

OrderService constructor.

Parameters

Type

Name

Description

OrderRepositoryContract

$orderRepository

BasketService

$basketService

SessionStorageRepositoryContract

$sessionStorageRepository

FrontendPaymentMethodRepositoryContract

$frontendPaymentMethodRepository

AddressRepositoryContract

$addressRepository

UrlService

$urlService

CheckoutService

$checkoutService

CustomerService

$customerService

ContactRepositoryContract

$contactRepository

GiftCardRepositoryContract

$giftCardRepository

public placeOrder():LocalizedOrder

Place an order

public subscribeToNewsletter($email, $billingAddressId)

Subscribe the customer to the newsletter, if stored in the session

Parameters

Type

Name

Description

string

$email

int

$billingAddressId

public executePayment($orderId, $paymentId):array

Execute the payment for a given order.

Parameters

Type

Name

Description

int

$orderId

The order id to execute payment for

int

$paymentId

The MoP-ID to execute

public findOrderById($orderId, $wrap = true):LocalizedOrder \| Order

Find an order by id

Parameters

Type

Name

Description

int

$orderId

An order id to find order by

bool

$wrap

Optional: Wrap order into an /IO/Models/LocalizedOrder (Default: true)

public findOrderByAccessKey($orderId, $orderAccessKey):LocalizedOrder

Find an order by id and authorize it via accesskey

Parameters

Type

Name

Description

int

$orderId

An order id find order by

string

$orderAccessKey

An order access key to authorize search for order

public getOrdersForContact($contactId, $page = 1, $items = 50, $filters = [], $wrapped = true): PaginatedResult

Get a list of orders for a contact

Parameters

Type

Name

Description

int

$contactId

An contacts id

int

$page

Optional: Page number for pagination (Default: 1)

int

$items

Optional: How many items per page (Default: 50)

array

$filters

Optional: Additional filters for search

bool

$wrapped

Optional: Wrap orders /IO/Models/LocalizedOrder instances (Default: true)

public getOrdersCompact($page = 1, $items = 50): PaginatedResult

Get a list of orders for a contact in a compact and reduced format

Parameters

Type

Name

Description

int

$page

Optional: Page for pagination (Default: 1)

int

$items

Optional: Number of items per page (Default: 50)

public getLatestOrderForContact($contactId):LocalizedOrder

Get the last order created by the current contact

Parameters

Type

Name

Description

int

$contactId

A contacts id to find orders for

public getOrderPropertyByOrderId($orderId, $typeId):         Collection \| array

Find order properties of a specific type for a specific order

Parameters

Type

Name

Description

int

$orderId

An order id to find order properties for

int

$typeId

The type of order properties to find

public isReturnActive():bool

Check if the shop has activated return orders

public createOrderReturn($orderId, $orderAccessKey = "", $items = [], $returnNote = ""):mixed

Create a return order for a specific order

Parameters

Type

Name

Description

int

$orderId

The order id to create a return order for

string

$orderAccessKey

Optional: An order access key is needed for guests

array

$items

Optional: Array of items to return

string

$returnNote

Optional: A optional reason for returning items

public getReturnOrder($orderId, $orderAccessKey = ""):LocalizedOrder

Find a return order by order id

Parameters

Type

Name

Description

int

$orderId

An order id to find return order for

string

$orderAccessKey

Optional: An order access key is needed to authorize guests

public getReturnableItems($order):array

Get all items of an order that can be returned

Parameters

Type

Name

Description

Order

$order

An order

public getPaymentMethodListForSwitch($currentPaymentMethodId, $orderId = null):Collection

List all payment methods available for switch in MyAccount

Parameters

Type

Name

Description

int

$currentPaymentMethodId

Optional: The id of the current payment method

int

$orderId

Optional: An order id to find valid payment methods to switch to

public allowPaymentMethodSwitchFrom($paymentMethodId, $orderId = null):bool

Check if it is possible to switch to another payment method from a specific one

Parameters

Type

Name

Description

int

$paymentMethodId

A payment method id to check switching from

int

$orderId

Optional: An order id used for additional checks

public switchPaymentMethodForOrder($orderId, $paymentMethodId):LocalizedOrder

Switch the payment method of an order to a new payment method

Parameters

Type

Name

Description

int

$orderId

An order id to switch payment method for

int

$paymentMethodId

A payment method id to switch to

public complete($order)

Do steps after creating the order

Parameters

Type

Name

Description

Order

$order