Shipping calculation
Description
Highlights
Features
About the Extension
Use of the plugin
The plugin adds the possibility to calculate shipping manually. To calculate shipping. costs you can use lineitems from the shopping cart as a price matrix.
Functionality
- It is possible to add manually shipping calculation in shipping method detail page.
- Default values added:
- SalesChannel
- LineItems (lineItem works only for foreach loop).
- If there is no float value to return then it will be used next matrix price if exist or default price.
Manual calculation of shipping costs
In the area Settings -> Shop-> Shipping -> Create or edit shipping type.
Here it is possible via a price matrix, to calculate the shipping manually.
In "lineItems" are all products from the cart. And there is added current "salesChannel" data.
You have lineItems form cart here and you can use them to calculate shipping.
Example #1: (set shipping costs to 10 without further rules)
{% set shipping = 10 %}{{ shipping }}
Example #2: (if there is product with a customField, than increase shipping costs)
{% for lineItem in lineItems %}
{% if lineItem.payload.customFields.attribute== "1" %}
{% set shipping = shipping + 1 %}
{% endif %}
{% endfor %}
{{ shipping }}
Important: When configuring the additional field in Admin under Settings > System > Additional fields, 'Available in shopping carts' must be activated for the respective additional fields.
Example #3: (Shipping costs based on number of products inside categories)
{% set numberProductsInsideCategory1 = 0 %}{% set numberProductsInsideCategory2 = 0 %}
{% for lineItem in lineItems %}
{% if lineItem.payload.categoryIds %}
{% for categoryId in lineItem.payload.categoryIds %}
{# Is product inside category 1 - we check it by the UUID #}
{% if categoryId == '21b199946c884aa294b409f135963880' %}
{% set numberProductsInsideCategory1 = numberProductsInsideCategory1 + 1 %}
{% endif %}
{# Is product inside category 2 - we check it by the UUID? #}
{% if categoryId == '0b5e8204e7034c2ca17a3899274874a4' %}
{% set numberProductsInsideCategory2 = numberProductsInsideCategory2 + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{# Now we can do something with the variables numberProductsInsideCategory1 and numberProductsInsideCategory2 #}
{% if numberProductsInsideCategory1 > 0 and numberProductsInsideCategory2 > 0 %}
19.90
{% elseif numberProductsInsideCategory1 > 0 %}
14.90
{% elseif numberProductsInsideCategory2 > 0 %}
12.90
{% else %}
9.90
{% endif %}
Note: Only the UUIDs of the categories (unique ID in the database) are available in the shopping cart. You can easily read out and copy the UUID via the plugin https://store.shopware.com/en/acris28622190382f/acris-display-category-id.html.
Example #4: Quantity detection
{% set quantity = 0 %}{% for lineItem in lineItems %}
{% if lineItem.quantity %}
{% set quantity = quantity + lineItem.quantity %}
{% endif %}
{% endfor %}
{{ quantity }}
Example #5: Customer custom field shipping free limit
{% set customerShippingFreeLimit = false %}
{% if customer.customFields is not empty and customer.customFields.custom_customer_shipping_free_limit > 0 %}
{% set customerShippingFreeLimit = customer.customFields.custom_customer_shipping_free_limit %}
{% endif %}
{% set shippingCosts = 9.95 %}
{% if customerShippingFreeLimit > 0 and cart.price.totalPrice >= customerShippingFreeLimit %}
{% set shippingCosts = 0 %}
{% endif %}
{{ shippingCosts }}
Example #6: Adding VAT to the net price of the shipping costs, depending on the country of delivery and the contents of the shopping basket
{% set shippingNet = 100 %}
{% if context.taxState == 'gross' and matchingTaxRules and matchingTaxRules.highestRate() %}
{% set shippingNet = shippingNet / 100 * matchingTaxRules.highestRate().getPercentage() %}
{% set shipping = shippingNet * (1 + (matchingTaxRules.highestRate().getTaxRate() / 100)) %}
{% else %}
{% set shipping = shippingNet %}
{% endif %}
{{ shipping }}
Example #7: Calculate price based on a different tax state in the cart (gross or net)
{% if context.taxState == 'gross' %}
{# do smth if tax state is gross #}
{% else %}
{# do smth if tax state is net #}
{% endif %}
Example #8: If at least one product is not in stock, shipping costs €10, otherwise €5
{% set oneProductOutOfStock = false %}
{% for lineItem in lineItems %}
{% if lineItem.deliveryInformation and lineItem.deliveryInformation.stock <= 0 %}
{% set oneProductOutOfStock = true %}
{% endif %}
{% endfor %}
{% if oneProductOutOfStock %}
10
{% else %}
5
{% endif %}
Possible variables
matchingTaxRules (Taxes relevant to the dispatch type, determined via tax type - PHP class TaxRuleCollection)
- matchingTaxRules.highestRate().getTaxRate()
currency
- currency.isoCode
- currency.factor
- currency.symbol
- currency.shortName
- currency.name
- currency.position
- currency.translations
- currency.orders
- currency.salesChannels
- currency.salesChannelDefaultAssignments
- currency.salesChannelDomains
- currency.shippingMethodPrices
- currency.promotionDiscountPrices
- currency.isSystemDefault
- currency.productExports
- currency.countryRoundings
- currency.itemRounding
- currency.totalRounding
- currency.taxFreeFrom
- currency.translated.customFields
context
- context.languageIdChain
- context.versionId
- context.currencyId
- context.currencyFactor
- context.scope
- context.ruleIds
- context.source
- context.considerInheritance
- context.taxState
- context.rounding
ruleIds - array with active rule ids
customer
- customer.groupId
- customer.defaultPaymentMethodId
- customer.salesChannelId
- customer.languageId
- customer.lastPaymentMethodId
- customer.defaultBillingAddressId
- customer.defaultShippingAddressId
- customer.customerNumber
- customer.salutationId
- customer.firstName
- customer.lastName
- customer.company
- customer.password
- customer.email
- customer.title
- customer.vatIds
- customer.affiliateCode
- customer.campaignCode
- customer.active
- customer.doubleOptInRegistration
- customer.doubleOptInEmailSentDate
- customer.doubleOptInConfirmDate
- customer.hash
- customer.guest
- customer.firstLogin
- customer.lastLogin
- customer.newsletter
- customer.birthday
- customer.lastOrderDate
- customer.orderCount
- customer.orderTotalAmount
- customer.createdAt
- customer.updatedAt
- customer.legacyEncoder
- customer.legacyPassword
- customer.group
- customer.defaultPaymentMethod
- customer.salesChannel
- customer.language
- customer.lastPaymentMethod
- customer.salutation
- customer.defaultBillingAddress
- customer.defaultShippingAddress
- customer.activeBillingAddress
- customer.activeShippingAddress
- customer.addresses
- customer.orderCustomers
- customer.autoIncrement
- customer.tags
- customer.tagIds
- customer.promotions
- customer.recoveryCustomer
- customer.productReviews
- customer.remoteAddress
- customer.requestedGroupId
- customer.requestedGroup
- customer.boundSalesChannelId
- customer.boundSalesChannel
- customer.wishlists
- customer.customFields
cart
- cart.name
- cart.token
- cart.price.netPrice
- cart.price.totalPrice
- cart.price.calculatedTaxes
- cart.price.taxRules
- cart.price.positionPrice
- cart.price.taxStatus
- cart.price.rawTotal
- cart.lineItems
- cart.errors
- cart.deliveries
- cart.transactions
- cart.modified
- cart.customerComment
- cart.affiliateCode
- cart.campaignCode
- cart.data
- cart.ruleIds
lineItems - array with line item
lineItem
- lineItem.id
- lineItem.referencedId
- lineItem.label
- lineItem.quantity
- lineItem.type
- lineItem.priceDefinition
- lineItem.price
- lineItem.good
- lineItem.description
- lineItem.cover
- lineItem.deliveryInformation
- lineItem.deliveryInformation.stock
- lineItem.deliveryInformation.weight
- lineItem.deliveryInformation.freeDelivery
- lineItem.deliveryInformation.restockTime
- lineItem.deliveryInformation.deliveryTime
- lineItem.deliveryInformation.height
- lineItem.deliveryInformation.width
- lineItem.deliveryInformation.length
- lineItem.children
- lineItem.requirement
- lineItem.removable
- lineItem.stackable
- lineItem.quantityInformation
- lineItem.modified
- lineItem.dataTimestamp
- lineItem.dataContextHash
- lineItem.payload
- lineItem.payload.isCloseout
- lineItem.payload.customFields
- lineItem.payload.createdAt
- lineItem.payload.releaseDate
- lineItem.payload.isNew
- lineItem.payload.markAsTopseller
- lineItem.payload.purchasePrices
- lineItem.payload.productNumber
- lineItem.payload.manufacturerId
- lineItem.payload.taxId
- lineItem.payload.tagIds
- lineItem.payload.categoryIds
- lineItem.payload.propertyIds
- lineItem.payload.optionIds
- lineItem.payload.options
- lineItem.payload.length
- lineItem.payload.height
- lineItem.payload.width
- lineItem.payload.deliveryTime
- lineItem.payload.features
- lineItem.deliveryInformation.weight
salesChannel
- salesChannel.typeId
- salesChannel.languageId
- salesChannel.currencyId
- salesChannel.paymentMethodId
- salesChannel.shippingMethodId
- salesChannel.countryId
- salesChannel.navigationCategoryId
- salesChannel.navigationCategoryDepth
- salesChannel.homeSlotConfig
- salesChannel.homeCmsPageId
- salesChannel.homeCmsPage
- salesChannel.homeEnabled
- salesChannel.homeName
- salesChannel.homeMetaTitle
- salesChannel.homeMetaDescription
- salesChannel.homeKeywords
- salesChannel.footerCategoryId
- salesChannel.serviceCategoryId
- salesChannel.name
- salesChannel.shortName
- salesChannel.accessKey
- salesChannel.currencies
- salesChannel.languages
- salesChannel.configuration
- salesChannel.active
- salesChannel.maintenance
- salesChannel.maintenanceIpWhitelist
- salesChannel.taxCalculationType
- salesChannel.type
- salesChannel.currency
- salesChannel.language
- salesChannel.paymentMethod
- salesChannel.shippingMethod
- salesChannel.country
- salesChannel.orders
- salesChannel.customers
- salesChannel.countries
- salesChannel.paymentMethods
- salesChannel.shippingMethods
- salesChannel.translations
- salesChannel.domains
- salesChannel.systemConfigs
- salesChannel.navigationCategory
- salesChannel.footerCategory
- salesChannel.serviceCategory
- salesChannel.productVisibilities
- salesChannel.mailHeaderFooterId
- salesChannel.numberRangeSalesChannels
- salesChannel.mailHeaderFooter
- salesChannel.customerGroupId
- salesChannel.customerGroup
- salesChannel.newsletterRecipients
- salesChannel.promotionSalesChannels
- salesChannel.documentBaseConfigSalesChannels
- salesChannel.productReviews
- salesChannel.seoUrls
- salesChannel.seoUrlTemplates
- salesChannel.mainCategories
- salesChannel.paymentMethodIds
- salesChannel.productExports
- salesChannel.hreflangActive
- salesChannel.hreflangDefaultDomainId
- salesChannel.hreflangDefaultDomain
- salesChannel.analyticsId
- salesChannel.analytics
- salesChannel.customerGroupsRegistrations
- salesChannel.eventActions
- salesChannel.boundCustomers
- salesChannel.wishlists
- salesChannel.landingPages
- salesChannel.translated.customFields
shippingMethod
- shippingMethod.translated.name
- shippingMethod.active
- shippingMethod.description
- shippingMethod.trackingUrl
- shippingMethod.deliveryTimeId
- shippingMethod.deliveryTime
- shippingMethod.translations
- shippingMethod.orderDeliveries
- shippingMethod.salesChannelDefaultAssignments
- shippingMethod.salesChannels
- shippingMethod.availabilityRule
- shippingMethod.availabilityRuleId
- shippingMethod.prices
- shippingMethod.mediaId
- shippingMethod.taxId
- shippingMethod.media
- shippingMethod.tags
- shippingMethod.taxType
- shippingMethod.tax
- shippingMethod.translated.customFields
paymentMethod
- paymentMethod.pluginId
- paymentMethod.handlerIdentifier
- paymentMethod.translated.name
- paymentMethod.distinguishableName
- paymentMethod.description
- paymentMethod.position
- paymentMethod.active
- paymentMethod.afterOrderEnabled
- paymentMethod.plugin
- paymentMethod.translations
- paymentMethod.orderTransactions
- paymentMethod.customers
- paymentMethod.salesChannelDefaultAssignments
- paymentMethod.salesChannels
- paymentMethod.availabilityRule
- paymentMethod.availabilityRuleId
- paymentMethod.mediaId
- paymentMethod.media
- paymentMethod.formattedHandlerIdentifier
- paymentMethod.shortName
- paymentMethod.appPaymentMethod
- paymentMethod.translated.customFields
customerGroup
- customerGroup.name
- customerGroup.translated.name
- customerGroup.displayGross
- customerGroup.translations
- customerGroup.customers
- customerGroup.salesChannels
- customerGroup.registrationActive
- customerGroup.registrationTitle
- customerGroup.registrationIntroduction
- customerGroup.registrationOnlyCompanyRegistration
- customerGroup.registrationSeoMetaDescription
- customerGroup.registrationSalesChannels
- customerGroup.translated.customFields
taxRules (Listing of taxes available in the shop - PHP class TaxCollection)
- taxRules.ids
- taxRules.elements
Extension as of plug-in version 2.2.0 - Determination of the tax rate
The tax rate relevant for the shipping method is determined in Shopware via the "tax type" (auto, highest rate or fixed rate). From now on we store the result of this in the variable "matchingTaxRules", this corresponds to the PHP class https://github.com/shopware/platform/blob/trunk/src/Core/Checkout/Cart/Tax/Struct/TaxRuleCollection.php. You can thus read out the current highest tax rate in the shopping cart via the following Twig variable:
{{ matchingTaxRules.highestRate().getTaxRate() }} You can now calculate with this tax rate.
Details
- Available: English, German
- Latest update: 4 December 2024
- Publication date: 19 March 2021
- Version: 4.0.3
- Category: Checkout / Cart process
Resources
Reviews (9)
Ein muss für jeden Shop mit komplexeren Versandlogiken. Top!
Exemplary support
Mächtiges, gut funktionierendes Werkzeug
Der Acris-Support, wenn man ihn mal benötigt, ist schnell und kompetent und hilft ersichtlich gerne.
Leider ist die Erweiterung überhaupt erst nötig, weil Shopware in SW6 keine Auf- und Abschlagsversandarten mehr bietet und eigene Regeln und Bedingungen ebenfalls nicht mehr möglich sind.
In SW5 konnte man unsere Anforderungen noch mit Hausmittel darstellen!
Endlich wieder individuelle Berechnungen
Mit diesem Plugin lassen sich eigentlich simple Berechnungen auch wieder simpel durchführen.
Beispielsweise Versandgewicht bis 5 kg = Preis x
Für jedes hinzu kommende KG zahlt der Kunde y, addieert auf x.
Kein Problem mit diesem Plugin.
P.S.: Schade, dass derartig nötige Funktionen nicht Standard sind.
Acris = Erweiterung und Support 1+
Der Support ist Weltklasse, antwortet schnell und präzise und hilft auch darüber hinaus, wo sie können.
Produkt und Service sind erstklassig
Endlich die Erweiterung nach der man sucht wenn man komplexen Versand berechnen will.
Essenzielle Erweiterung
Tut was es soll
Hatte einige Probleme und Fragen zum Versand, die alle schnell und erfolgreich gelöst werden konnten.
About the Extension Partner
ACRIS E-Commerce GmbH
Partner Status
-
Shopware
Gold Partner -
Shopware
Premium Extension Partner
Details
- Ø-Rating: 4.9
- Partner since: 2015
- Extensions: 122
Support
- Based in: Austria
- Speaks: German, English
- Response time: Very quickly