ePages 7.19.0 - DE_EPAGES/Order/API/Order.pm

Package DE_EPAGES::Order::API::Order

This package provides the main customer order functions.

@EXPORT_OK
Basket2Order
SendOrderConfirmationMail
SendStatusChangeMail
SendStatusChangeMails
GetEditableOrder
CreateOrder
CreateOrderWithContainer
CreateOrderWithoutContainer
SendOrderDocumentAsPDFMail
GetLatestOrderInvoice
GenerateOrderDocumentPDF
GetLabelImagePath

Functions

Basket2Order
CreateOrder
CreateOrderWithContainer
CreateOrderWithoutContainer
GenerateOrderDocumentPDF
GetEditableOrder
GetLabelImagePath
GetLatestOrderInvoice
SendOrderConfirmationMail
SendOrderDocumentAsPDFMail
SendStatusChangeMail
SendStatusChangeMails

Basket2Order

Creates a customer order by a basket and deletes the basket at the end. Addresses will be copied and lineitemcontainer will be moved to new order.

Syntax
$Order = Basket2Order($Basket);
$Order = Basket2Order($Basket, $hOptions);
Example
$Order = Basket2Order($Basket, { SendConfirmationMail => 1 });
Input
$Basket (object)
basket
$hOptions (ref.hash)
(optional) order creation options.
This hash is passed to the hooks triggerd by this function.
  • SendConfirmationMail - trigger mail event 'CustomerOrderConfirmation',
    which sends order confirmation e-mail
    (optional, default=1) - boolean
Return
$Order (object)
new customer order
Hook
API_Basket2Order
triggered in basket to order transaction, hook parameter keys :
  • Basket - basket - object
  • Order - customer order - object
  • Options - order creation options - ref.hash
API_OrderCreated
triggered after order creation, hook parameter keys :
  • Order - customer order - object
  • Options - order creation options - ref.hash

CreateOrder

Creates an empty order which will belong to the given customer. Addresses are copied and an empty lineitemcontainer is added. Sets the default shipping and payment method.

Syntax
$Order = CreateOrder($Customer, $hVars);
Input
$Customer (object)
customer
$hVars (ref.hash (optional))
  • CurrencyID - (optional; default: shop default currency) alpha currency code (ISO 4217) - char(3)
  • TaxModel - (optional; default: customer tax model) gross (1) or net (0) price - int
Return
$Order (object)
new customer order

CreateOrderWithContainer

Creates an empty order for a customer without shipping and payment methods and without billing/shipping address. Creates a lineitem container and sets the shop address.

Syntax
$Order = CreateOrderWithContainer( $Customer, $hValues );
Example
Transaction( sub {
    $Order = CreateOrderWithContainer( $Customer, { 'Alias' => '1001' } );
    $Order->set({
        'BillingAddress' => $Customer->get('BillingAddress')->clone({ 'Parent' => $Order, 'Alias' => 'BillingAddress' }),
    });
});
Input
$Customer (object)
customer
$hValues (ref.hash (optional))
  • CurrencyID - (optional; default: user currency or shop default currency) alpha currency code (ISO 4217) - char(3)
  • LocaleID - (optional; default: user locale or shop default locale) locale id - string
  • TaxArea - (optional; default: customer tax area) tax area - DE_EPAGES::Tax::API::Object::TaxArea
  • TaxModel - (optional; default: customer tax model) gross (1) or net (0) price - int
  • User - (optional; default: first user of customer or undef) user - object
  • Alias - (optional; default: generate new order number) order number - string
Return
$Order (object)
new customer order

CreateOrderWithoutContainer

Creates an empty order which for a customer without line item container and without shop address.

Syntax
$Order = CreateOrderWithoutContainer( $Customer, $hValues );
Example
Transaction( sub {
    $Order = CreateOrderWithoutContainer( $Customer, { 'Alias' => '1001' } );
    $Order->addLineItemContainer;
    $Order->set({
        'BillingAddress' => $Customer->get('BillingAddress')->clone({ 'Parent' => $Order, 'Alias' => 'BillingAddress' }),
        'ShopAddress' => $Shop->get('Address')->clone({ 'Parent'=>$Order, 'Alias'=> 'ShopAddress' }),
    });
});
Input
$Customer (object)
customer
$hValues (ref.hash (optional))
  • User - (optional; default: first user of customer or undef) user - object
  • Alias - (optional; default: generate new order number) order number - string
  • GUID - (optional; default: generate new GUID) GUID - string
Return
$Order (object)
new customer order

GenerateOrderDocumentPDF

Converts order document (invoice, packing slip, credit note or shipping label) to pdf document.

Syntax
$hPdfContent = GenerateOrderDocumentPDF($Invoice);
Input
$OrderDocument (object)
OrderDocument
Return
$hPdfContent (ref.hash)
  • pdf - pdf document - binary
  • filename - name of pdf file - string

GetEditableOrder

Returns the editable order (copy and possible changed copy of order). If no editable order exists this function returns undef.

Syntax
$EditableOrder = GetEditableOrder($Order);
Input
$Order (object)
customer order
Return
$EditableOrder (string)
copy of order (optional)

GetLabelImagePath

Sets and returns the path for the barcode image of a shipping label. Used by USPS when issueing (triggering) a shipping label (to store the recieved pdf) and when sending it by email (from the MBO order documents page). It could also be used by SEUR (since it has its own but exaclty the same function) and other delivery cartridges...

Syntax
$Path = GetLabelImagePath($ShippingLabel, $FileExtension);
Example
my $Path  = GetLabelImagePath($ShippingLabel, 'pdf');
Input
$ShippingLabel (object)
shipping label object
$FileExtension (string)
image file extension
Return
$LabelImagePath (string)
path and image name

GetLatestOrderInvoice

Returns the latest invoice document of an order

Syntax
GetLatestOrderInvoice($Order);
Input
$Order (object)
Order
Return
$Invoice (object)
invoice

SendOrderConfirmationMail

Send a confirmation mail to customer (Order.BillingAddress.EMail is used). The activated shop mail type 'CustomerOrderConfirmation' is used to define the content of the mail.

Syntax
SendOrderConfirmationMail($Order);
Input
$Order (object)
customer order

SendOrderDocumentAsPDFMail

Send an order document as pdf file mail to customer (Order.BillingAddress.EMail is used). The activated shop mail type 'OrderDocumentPDF' is used to define the content of the mail. The OrderDocument must be Invoice, PackingSlip, CreditNote, or ShippingLabel.

Syntax
SendOrderDocumentAsPDFMail($OrderDocument, $Servlet);
Input
$OrderDocument (object)
order document
$Servlet (object)
the servlet

SendStatusChangeMail

Send a status changed mail to customer (Order.BillingAddress.EMail is used). The activated shop mail type 'CustomerOrderStatus$Event' is used to define the content of the mail. This mail will not be send on event 'ArchivedOn'.

Syntax
SendStatusChangeMail($Order, $Event);
Input
$Order (object)
customer order
$Event (string)
name of order status

SendStatusChangeMails

Sends order status notification e-mails to the customer if a status was set (from null to not null). The e-mail address Order.BillingAddress.EMail is used. See also SendStatusChangeMail.

Syntax
SendStatusChangeMails($Order, $hOldStatus, $hNewStatus);
Input
$Order (object)
customer order
$hOldStatus (ref.hash.)
pevious status change dates
$hStatus (ref.hash)
new status change dates (name => DateTime).
This hash may contain other attribute values, but only the status
attributes defined in DE_EPAGES::Order::API::Constants
will be used.