ePages 6.10 - 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
getLevels
levels
price
setLevels
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

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

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

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

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