order

package
v1.4.5-alpha1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2019 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package order is a default implementation of interfaces declared in "github.com/ottemo/commerce/app/models/order" package

Index

Constants

View Source
const (
	ConstConfigPathOrderGroup            = "general.order"
	ConstConfigPathShippingEmailSubject  = "general.order.shipping_status_email_subject"
	ConstConfigPathShippingEmailTemplate = "general.order.shipping_status_email_template"
)

Configuration settings for order package

View Source
const (
	ConstCollectionNameOrder      = "orders"
	ConstCollectionNameOrderItems = "order_items"

	ConstIncrementIDFormat = "%0.10d"

	ConstConfigPathLastIncrementID = "internal.order.increment_id"

	ConstErrorModule = "order"
	ConstErrorLevel  = env.ConstErrorLevelActor
)

Package global constants

Variables

This section is empty.

Functions

func APIChangeOrderStatus

func APIChangeOrderStatus(context api.InterfaceApplicationContext) (interface{}, error)

APIChangeOrderStatus will change orders to the state included in the status request variable

  • order ids should be specified in "IDs" argument
  • status should be specified in "status" argument

func APIDeleteOrder

func APIDeleteOrder(context api.InterfaceApplicationContext) (interface{}, error)

APIDeleteOrder deletes existing purchase order

  • order id should be specified in "orderID" argument

func APIExportOrders

func APIExportOrders(context api.InterfaceApplicationContext) (interface{}, error)

APIExportOrders returns a list of orders in CSV format

  • returns orders specified in url parameters
  • must include at least one order

func APIGetOrder

func APIGetOrder(context api.InterfaceApplicationContext) (interface{}, error)

APIGetOrder return specified purchase order information

  • order id should be specified in "orderID" argument

func APIGetVisitorOrder

func APIGetVisitorOrder(context api.InterfaceApplicationContext) (interface{}, error)

APIGetVisitorOrder returns current visitor order details for specified order

  • orderID should be specified in arguments

func APIGetVisitorOrders

func APIGetVisitorOrders(context api.InterfaceApplicationContext) (interface{}, error)

APIGetVisitorOrders returns list of orders related to current visitor

  • visitorID is required, visitor must be logged in

func APIListOrderAttributes

func APIListOrderAttributes(context api.InterfaceApplicationContext) (interface{}, error)

APIListOrderAttributes returns a list of purchase order attributes

func APIListOrders

func APIListOrders(context api.InterfaceApplicationContext) (interface{}, error)

APIListOrders returns a list of existing purchase orders

  • if "action" parameter is set to "count" result value will be just a number of list items

func APISendOrderConfirmationEmail

func APISendOrderConfirmationEmail(context api.InterfaceApplicationContext) (interface{}, error)

APISendOrderConfirmationEmail will send out an order confirmation email to the visitor specficied in the orderID

  • orderID must be passed as a request argument

func APISendShipStatusEmail

func APISendShipStatusEmail(context api.InterfaceApplicationContext) (interface{}, error)

APISendShipStatusEmail will send the visitor a shipping confirmation email - order id should be specified in "orderID" argument

func APIUpdateOrder

func APIUpdateOrder(context api.InterfaceApplicationContext) (interface{}, error)

APIUpdateOrder update existing purchase order

  • order id should be specified in "orderID" argument

func APIUpdateTrackingInfoAndSendEmail

func APIUpdateTrackingInfoAndSendEmail(context api.InterfaceApplicationContext) (interface{}, error)

APIUpdateTrackingInfoAndSendEmail updates order with shipping tracking information and sends a shipping status email - carrier, tracking_number, tracking_url are required

Types

type DefaultOrder

type DefaultOrder struct {
	IncrementID string
	Status      string

	SessionID string
	VisitorID string
	CartID    string

	Description  string
	PaymentInfo  map[string]interface{}
	CustomInfo   map[string]interface{}
	ShippingInfo map[string]interface{}

	BillingAddress  map[string]interface{}
	ShippingAddress map[string]interface{}

	CustomerEmail string
	CustomerName  string

	PaymentMethod  string
	ShippingMethod string

	Subtotal       float64
	Discount       float64
	TaxAmount      float64
	ShippingAmount float64
	GrandTotal     float64

	Taxes     []order.StructTaxRate
	Discounts []order.StructDiscount

	Notes []string

	CreatedAt time.Time
	UpdatedAt time.Time

	Items map[int]order.InterfaceOrderItem
	// contains filtered or unexported fields
}

DefaultOrder is a default implementer of InterfaceOrder

func (*DefaultOrder) AddItem

func (it *DefaultOrder) AddItem(productID string, qty int, productOptions map[string]interface{}) (order.InterfaceOrderItem, error)

AddItem adds line item to current order, or returns error

func (*DefaultOrder) CalculateTotals

func (it *DefaultOrder) CalculateTotals() error

CalculateTotals recalculates order Subtotal and GrandTotal

func (*DefaultOrder) Delete

func (it *DefaultOrder) Delete() error

Delete removes current order from DB

func (*DefaultOrder) DuplicateOrder

func (it *DefaultOrder) DuplicateOrder(params map[string]interface{}) (interface{}, error)

DuplicateOrder used to create checkout from order with changing params main params for duplication: sessionID, paymentMethod, shippingMethod

func (*DefaultOrder) FromHashMap

func (it *DefaultOrder) FromHashMap(input map[string]interface{}) error

FromHashMap fills Order attributes with values provided in input map

func (*DefaultOrder) Get

func (it *DefaultOrder) Get(attribute string) interface{}

Get returns attribute of Order or nil

func (*DefaultOrder) GetAttributesInfo

func (it *DefaultOrder) GetAttributesInfo() []models.StructAttributeInfo

GetAttributesInfo describes attributes of Order model

func (*DefaultOrder) GetBillingAddress

func (it *DefaultOrder) GetBillingAddress() visitor.InterfaceVisitorAddress

GetBillingAddress returns billing address for order

func (*DefaultOrder) GetCollection

func (it *DefaultOrder) GetCollection() models.InterfaceCollection

GetCollection returns collection of current instance type

func (*DefaultOrder) GetDiscountAmount

func (it *DefaultOrder) GetDiscountAmount() float64

GetDiscountAmount returns discount amount applied to order

func (*DefaultOrder) GetDiscounts

func (it *DefaultOrder) GetDiscounts() []order.StructDiscount

GetDiscounts returns discount applied to order

func (*DefaultOrder) GetGrandTotal

func (it *DefaultOrder) GetGrandTotal() float64

GetGrandTotal returns grand total of order

func (*DefaultOrder) GetID

func (it *DefaultOrder) GetID() string

GetID returns id of current order

func (*DefaultOrder) GetImplementationName

func (it *DefaultOrder) GetImplementationName() string

GetImplementationName returns name of current model implementation

func (*DefaultOrder) GetIncrementID

func (it *DefaultOrder) GetIncrementID() string

GetIncrementID returns increment id of order

func (*DefaultOrder) GetItems

func (it *DefaultOrder) GetItems() []order.InterfaceOrderItem

GetItems returns order items for current order

func (*DefaultOrder) GetModelName

func (it *DefaultOrder) GetModelName() string

GetModelName returns model name we have implementation for

func (*DefaultOrder) GetPaymentMethod

func (it *DefaultOrder) GetPaymentMethod() string

GetPaymentMethod returns payment method used for order

func (*DefaultOrder) GetShippingAddress

func (it *DefaultOrder) GetShippingAddress() visitor.InterfaceVisitorAddress

GetShippingAddress returns shipping address for order

func (*DefaultOrder) GetShippingAmount

func (it *DefaultOrder) GetShippingAmount() float64

GetShippingAmount returns order shipping cost

func (*DefaultOrder) GetShippingMethod

func (it *DefaultOrder) GetShippingMethod() string

GetShippingMethod returns shipping method for order

func (*DefaultOrder) GetStatus

func (it *DefaultOrder) GetStatus() string

GetStatus returns current order status

func (*DefaultOrder) GetSubtotal

func (it *DefaultOrder) GetSubtotal() float64

GetSubtotal returns subtotal of order

func (*DefaultOrder) GetTaxAmount

func (it *DefaultOrder) GetTaxAmount() float64

GetTaxAmount returns tax amount applied to order

func (*DefaultOrder) GetTaxes

func (it *DefaultOrder) GetTaxes() []order.StructTaxRate

GetTaxes returns taxes applied to order

func (*DefaultOrder) Load

func (it *DefaultOrder) Load(ID string) error

Load loads order information from DB

func (*DefaultOrder) New

func (it *DefaultOrder) New() (models.InterfaceModel, error)

New makes new instance of model

func (*DefaultOrder) NewIncrementID

func (it *DefaultOrder) NewIncrementID() error

NewIncrementID assigns new unique increment id to order

func (*DefaultOrder) Proceed

func (it *DefaultOrder) Proceed() error

Proceed subtracts order items from stock, changes status to new if status was not set yet, saves order

func (*DefaultOrder) RemoveAllItems

func (it *DefaultOrder) RemoveAllItems() error

RemoveAllItems removes all items from current order, or returns error

func (*DefaultOrder) RemoveItem

func (it *DefaultOrder) RemoveItem(itemIdx int) error

RemoveItem removes line item from current order, or returns error

func (*DefaultOrder) Rollback

func (it *DefaultOrder) Rollback() error

Rollback returns order items to stock, modifieds the order status to declined if status was not set yet, then saves order

func (*DefaultOrder) Save

func (it *DefaultOrder) Save() error

Save stores current order in DB

func (DefaultOrder) SendOrderConfirmationEmail

func (it DefaultOrder) SendOrderConfirmationEmail() error

SendOrderConfirmationEmail will send an order confirmation based on the detail of the current order

func (DefaultOrder) SendShippingStatusUpdateEmail

func (it DefaultOrder) SendShippingStatusUpdateEmail() error

SendShippingStatusUpdateEmail will send an email to alert customers their order has been packed and shipped

func (*DefaultOrder) Set

func (it *DefaultOrder) Set(attribute string, value interface{}) error

Set sets attribute to Order object, returns error on problems

func (*DefaultOrder) SetID

func (it *DefaultOrder) SetID(NewID string) error

SetID sets id for order

func (*DefaultOrder) SetIncrementID

func (it *DefaultOrder) SetIncrementID(incrementID string) error

SetIncrementID sets increment id to order

func (*DefaultOrder) SetStatus

func (it *DefaultOrder) SetStatus(newStatus string) error

SetStatus changes status for current order

  • if status change no supposing stock operations, order instance will not be saved automatically

func (*DefaultOrder) ToHashMap

func (it *DefaultOrder) ToHashMap() map[string]interface{}

ToHashMap makes map from Order attribute values

type DefaultOrderCollection

type DefaultOrderCollection struct {
	// contains filtered or unexported fields
}

DefaultOrderCollection is a default implementer of InterfaceOrderCollection

func (*DefaultOrderCollection) GetDBCollection

func (it *DefaultOrderCollection) GetDBCollection() db.InterfaceDBCollection

GetDBCollection returns database collection

func (*DefaultOrderCollection) GetImplementationName

func (it *DefaultOrderCollection) GetImplementationName() string

GetImplementationName returns model implementation name

func (*DefaultOrderCollection) GetModelName

func (it *DefaultOrderCollection) GetModelName() string

GetModelName returns model name

func (*DefaultOrderCollection) List

List enumerates items of Product model type

func (*DefaultOrderCollection) ListAddExtraAttribute

func (it *DefaultOrderCollection) ListAddExtraAttribute(attribute string) error

ListAddExtraAttribute allows to obtain additional attributes from List() function

func (*DefaultOrderCollection) ListFilterAdd

func (it *DefaultOrderCollection) ListFilterAdd(Attribute string, Operator string, Value interface{}) error

ListFilterAdd adds selection filter to List() function

func (*DefaultOrderCollection) ListFilterReset

func (it *DefaultOrderCollection) ListFilterReset() error

ListFilterReset clears presets made by ListFilterAdd() and ListAddExtraAttribute() functions

func (*DefaultOrderCollection) ListLimit

func (it *DefaultOrderCollection) ListLimit(offset int, limit int) error

ListLimit specifies selection paging

func (*DefaultOrderCollection) ListOrders

func (it *DefaultOrderCollection) ListOrders() []order.InterfaceOrder

ListOrders returns array of products in model instance form

func (*DefaultOrderCollection) New

New returns new instance of model implementation object

type DefaultOrderItem

type DefaultOrderItem struct {
	OrderID string

	ProductID string

	Qty int

	Name string
	Sku  string

	ShortDescription string

	Options map[string]interface{}

	Price  float64
	Weight float64
	// contains filtered or unexported fields
}

DefaultOrderItem is a default implementer of InterfaceOrderItem

func (*DefaultOrderItem) FromHashMap

func (it *DefaultOrderItem) FromHashMap(input map[string]interface{}) error

FromHashMap fills OrderItem attributes with values provided in input map

func (*DefaultOrderItem) Get

func (it *DefaultOrderItem) Get(attribute string) interface{}

Get returns attribute of OrderItem or nil

func (*DefaultOrderItem) GetAttributesInfo

func (it *DefaultOrderItem) GetAttributesInfo() []models.StructAttributeInfo

GetAttributesInfo describes attributes of OrderItem model

func (*DefaultOrderItem) GetID

func (it *DefaultOrderItem) GetID() string

GetID returns order item unique id, or blank string

func (*DefaultOrderItem) GetName

func (it *DefaultOrderItem) GetName() string

GetName returns order item product name

func (*DefaultOrderItem) GetOptionValues

func (it *DefaultOrderItem) GetOptionValues(labels bool) map[string]interface{}

GetOptionValues returns order item options values optionId: optionValue or optionLabel: optionValueLabel

func (*DefaultOrderItem) GetOptions

func (it *DefaultOrderItem) GetOptions() map[string]interface{}

GetOptions returns order item product options

func (*DefaultOrderItem) GetPrice

func (it *DefaultOrderItem) GetPrice() float64

GetPrice returns order item product price

func (*DefaultOrderItem) GetProductID

func (it *DefaultOrderItem) GetProductID() string

GetProductID returns product ID which order item represents

func (*DefaultOrderItem) GetQty

func (it *DefaultOrderItem) GetQty() int

GetQty returns order line item qty ordered

func (*DefaultOrderItem) GetSku

func (it *DefaultOrderItem) GetSku() string

GetSku returns order item product sku

func (*DefaultOrderItem) GetWeight

func (it *DefaultOrderItem) GetWeight() float64

GetWeight returns order item product weight

func (*DefaultOrderItem) Set

func (it *DefaultOrderItem) Set(attribute string, value interface{}) error

Set sets attribute to OrderItem object, returns error on problems

func (*DefaultOrderItem) SetID

func (it *DefaultOrderItem) SetID(newID string) error

SetID sets order item unique id

func (*DefaultOrderItem) ToHashMap

func (it *DefaultOrderItem) ToHashMap() map[string]interface{}

ToHashMap makes map from OrderItem attribute values

type DefaultOrderItemCollection

type DefaultOrderItemCollection struct {
	// contains filtered or unexported fields
}

DefaultOrderItemCollection is a default implementer of InterfaceOrderItemCollection

func (*DefaultOrderItemCollection) GetDBCollection

func (it *DefaultOrderItemCollection) GetDBCollection() db.InterfaceDBCollection

GetDBCollection returns database collection

func (*DefaultOrderItemCollection) GetImplementationName

func (it *DefaultOrderItemCollection) GetImplementationName() string

GetImplementationName returns model implementation name

func (*DefaultOrderItemCollection) GetModelName

func (it *DefaultOrderItemCollection) GetModelName() string

GetModelName returns model name

func (*DefaultOrderItemCollection) List

List enumerates items of Product model type

func (*DefaultOrderItemCollection) ListAddExtraAttribute

func (it *DefaultOrderItemCollection) ListAddExtraAttribute(attribute string) error

ListAddExtraAttribute allows to obtain additional attributes from List() function

func (*DefaultOrderItemCollection) ListFilterAdd

func (it *DefaultOrderItemCollection) ListFilterAdd(Attribute string, Operator string, Value interface{}) error

ListFilterAdd adds selection filter to List() function

func (*DefaultOrderItemCollection) ListFilterReset

func (it *DefaultOrderItemCollection) ListFilterReset() error

ListFilterReset clears presets made by ListFilterAdd() and ListAddExtraAttribute() functions

func (*DefaultOrderItemCollection) ListLimit

func (it *DefaultOrderItemCollection) ListLimit(offset int, limit int) error

ListLimit specifies selection paging

func (*DefaultOrderItemCollection) New

New returns new instance of model implementation object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL