ePages 6.17.9 - DE_EPAGES/Shipping/API/Object/ShippingMethod.pm

Package DE_EPAGES::Shipping::API::Object::ShippingMethod

object interface for ShippingMethod.

Base
DE_EPAGES::Object::API::Object::Object

Functions

canDelete
className
dbPackage
discount
exportXMLAttributes
featureName
getLevels
getShippingValues
hasSettings
levels
price
setLevels
setShippingValues
template
usableAtStorefront

canDelete

In case of the default shipping method a warning is added. The default shipping method can't be deleted.

Syntax
$Object->canDelete($aWarnings);
Input
$aWarnings (array.ref)
array of Warning Objects
Return
$Deleteable (boolean)
true if shipping method can be deleted

className

Returns the class name, used for DAL access.

Syntax
$ClassName = $ShippingMethod->className;
Return
$ClassName (String)
class name

dbPackage

Returns the database package, used for DAL access.

Syntax
$DbPackage = $ShippingMethod->dbPackage;
Return
$DbPackage (String)
database package name

discount

Returns the shipping discount by the given requirements. The hook 'ShippingDiscount' is triggered before the standard discount = 0.

Syntax
$ShippingDiscount = $Object->discount( $hVars );
Example
$ShippingDiscount = $ShippingMethod->discount( {
    CurrencyID => 'USD',
    TaxModel => $ShippingMethod->getSite()->get('TaxModel')
} );
Input
$hVars (ref.hash)
  • CurrencyID - alpha currency code (ISO 4217) - char(3)
  • TaxModel - gross or net price - int
  • ShippingElements
    • Element - e.g. Products - object
    • Quantity - quantity of element - float
    | ref.array.hash
Return
$ShippingDiscount (money)
discount of shipping

exportXMLAttributes

Returns plain attributes of object to XML export driver. This function removes bit attributes with value 0.

Syntax
$hAttributes = $Object->exportXMLAttributes( $Driver, $hAllAttributes );
Input
$Driver (object)
xml export driver with support function addObject
$hAllAttributes (ref.hash)
all attributes of object,
see $Object->exportableAttributes
Return
$hAttributes (ref.hash.string)
plain attributes

featureName

Returns the feature name.

Syntax
$FeatureName = $ShippingMethod->featureName;
Return
$FeatureName (String)
feature name (undef means no feature count)

getLevels

Return the shipping levels for the given currency in the requested tax model.

Syntax
$ahLevels = $Object->getLevels($CurrencyID, $TaxModel);
$ahLevels = $Object->getLevels($CurrencyID, $TaxModel, $ExtraPrecision);
Input
$CurrencyID (char(3))
currency id
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
$ExtraPrecision (boolean)
(optional, default=0) extra precision for net prices
in back-office
Return
$ahLevels (int)
list of hashes, keys:
BaseValue, LowerBound, UpperBound, Multiplier, ShippingLevelID

getShippingValues

Return the shipping values for the given currency in the requested tax model.

Syntax
$hShippingValues = $Object->getShippingValues($CurrencyID, $TaxModel);
$hShippingValues = $Object->getShippingValues($CurrencyID, $TaxModel, $ExtraPrecision);
Input
$CurrencyID (char(3))
currency id
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
$ExtraPrecision (boolean)
(optional, default=0) extra precision for net prices
in back-office
Return
$hShippingValues (hash.ref)
hash, keys:
FreeShippingPrice (optional), MaximumWeight (optional)

hasSettings

Returns true if the shipping method has any settings, i.e. if the tab page "Settings" should be displayed. The default implementation always returns true.

Syntax
$HasSettings = $Object->hasSettings;
Return
$HasSettings (boolean)
true if the shipping method has any settings

levels

Returns all shipping level objects of that shipping method.

Syntax
$aShippingLevels = $Object->levels;
Return
$aShippingLevels (ref.array.object)
list of shipping level opbjects

price

Returns the shipping price by the given requirements. Needs to be implemented for a new shipping method.

Syntax
$ShippingPrice = $Object->price( $hVars );
Example
$Product = LoadObjectByPath('/Shops/DemoShop/Products/0815');
$ShippingPrice = $ShippingPrice = $ShippingMethod->price({
    'CurrencyID' => 'EUR',
     'TaxModel'  => 1,
     'ShippingElements' => [ { 'Element' =>  $Product,
                               'Quantity' => 1,
                           } ]
});
Input
$hVars (ref.hash)
  • CurrencyID - alpha currency code (ISO 4217) - char(3)
  • TaxModel - gross or net price - int
  • ShippingElements
    • Element - e.g. Products - object
    • Quantity - quantity of element - float
    | ref.array.hash
Return
$ShippingPrice (money)
price of shipping

setLevels

Sets all shipping levels for the given currency. Deletes shipping levels that are not included in the list. Calculates net prices from gross prices if $TaxModel is TAX_MODEL_GROSS.

Syntax
$Object->setLevels($CurrencyID, $TaxModel, $ahLevels);
Input
$CurrencyID (char(3))
currency id
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
$ahLevels (int)
list of hashes, keys:
BaseValue, LowerBound, UpperBound, Multiplier

setShippingValues

Sets all shipping values for the given currency. Calculates net prices from gross prices if $TaxModel is TAX_MODEL_GROSS.

Syntax
$Object->setShippingValues($CurrencyID, $TaxModel, $ahShippingValues);
Input
$CurrencyID (char(3))
currency id
$TaxModel (int)
tax model (1=gross/including tax, 0=net/without tax)
$hShippingValues (hash.ref)
hash, keys:
FreeShippingPrice, MaximumWeight

template

This function is used to overwrite the given template for the purpose that each shipping method can define there own template (visualisation).

Syntax
$Name = $Object->template($Name, $ObjectPageType);
Input
$Name (string)
include name
$ObjectPageType (DE_EPAGES::Presentation::API::Object::ObjectPageType)
object related pagetype
Return
$Name (string)
include name

usableAtStorefront

Tests if a shipping method with the given currency is visible in the storefront. Uses function DE_EPAGES::Shipping::API::Object::ShippingMethod::price to evaluate if shipping methode has a price (price can be 0).

Syntax
$Usable = $ShippingMethod->usableAtStorefront($hVars);
Input
$hVars (ref.hash)
  • CurrencyID - alpha currency code (ISO 4217) - char(3)
  • TaxModel - gross or net price - int
Return
$Usable (boolean)
true if shipping method is usable in the storefront