Package DE_EPAGES::FedEx::API::Object::ShippingMethodDynamicalFedEx
Shipping method for shipping price calculation for #PackageName
Functions
- addToContainer
- canAddToBasket
- usableAtStorefront
addToContainer
Adds shipping and tax line item to container.
Syntax |
$LineItem = $ShippingMethod->addToContainer($Container);
|
Input |
- $Container (object)
- line item container
|
Return |
- $LineItem (object
sub addToContainer { my $self = shift; my ($Container) = @_; return $Container->insertLineItem($self->get('ShippingType')->get('LineItemClass'), $self->lineItem($Container)); })
- line item
|
canAddToBasket
Tests if a shipping method can be added to the basket with the given currency.
Uses function DE_EPAGES::Shipping::API::Object::ShippingMethod::price
to evaluate if shipping methode has a price (price can be 0). Possible for
methods, which costs, but have no price in the given currency.
Syntax |
$Can = $ShippingMethod->canAddToBasket($hVars);
|
Input |
- $hVars (ref.hash)
- vars of container and basket
|
Return |
- $Can (boolean
sub canAddToBasket { my $self = shift; my ($hVars) = @_; return 0 unless $self->get('IsActivated'); return 0 unless $self->get('ShippingType')->get('IsActivated'); #test regions my $Region= $self->get('Region'); if (defined $Region) { $hVars->{'ShippingCountryID'} = $hVars->{'LineItemContainer'}->get('ShippingCountryID') if defined $hVars->{'LineItemContainer'} and not defined $hVars->{'ShippingCountryID'}; if (defined $hVars->{'ShippingCountryID'}) { return 0 unless grep {$_->{'CountryID'} == $hVars->{'ShippingCountryID'}} @{$Region->get('Countries')}; } } # test customer groups my $CustomerGroups = $self->get('CustomerGroups'); if (scalar @$CustomerGroups) { my $CustomerGroup = $hVars->{'CustomerGroup'}; if(not defined $CustomerGroup and defined $hVars->{'LineItemContainer'}) { my $ContainerParent = $hVars->{'LineItemContainer'}->businessContainer->parent; my $Customer = $ContainerParent->get('Customer'); if (not defined $Customer) { my $User = $ContainerParent->get('User'); $Customer = GetCustomerForUser($User, $ContainerParent->getSite()) if defined $User; } $CustomerGroup = $Customer->get('CustomerGroup') if defined $Customer; } $CustomerGroup = $CustomerGroups->[0]->getSite()->get('NonMemberCustomerGroup') unless defined $CustomerGroup; $hVars->{'CustomerGroup'} = $CustomerGroup; return 0 if not defined $CustomerGroup or not grep { $_->id == $CustomerGroup->id } @$CustomerGroups; } return $self->usableAtStorefront($hVars); })
- can added to the basket
|
usableAtStorefront
Tests if the shipping method is usable in the storefront.
overwrites DE_EPAGES::Shipping::API::Object::ShippingMethod.usableAtStorefront
Syntax |
$Usable = $ShippingMethod->usableAtStorefront();
|
Input |
-
- ---
|
Return |
- $Usable (boolean)
- true if shipping method is usable in the storefront
|