Use in the shopware productfeeds

In the templates of the productfeeds, a new field is added to the variable $sArticle

$sArticle.mnd_addcharge
This variable contains an object with surcharge information:
VariableDescriptionExampleType
nameThe "Internal Name" of the surcharge/discount.cansdeposit_1string
display_name
name of the surcharge/discount for the customer
Reusable cans deposit
string
description

The description of the surcharge/discount.

The description may contain newline characters. You should convert the value according to your target format. (e.g. CSV does not like line wraps)
reusable cans deposit is mandatory in Germany.
string
price
The gross price of the deposit in the currency opposed for the export.
0.25float
tax
The tax rate of the deposit/discount.
19.00float
type

Surcharge type. There are three types.

DescriptionKeywordCalculation

surcharge/discount quantity equals article quantity

multi

article quantity 10 = 10x surcharge/discount

Only one per article

singlearticle quantity 10 = 1x surcharge/discount, 15 = 1x surcharge/discount ...

Only one per basket

basketOne surcharge/discount per basket. Surcharge/discount will only be factored 1x per shopping cart. Regardless of number of articles and resp. quantity.
multi | single | basketstring
optionalshows if a surcharge/discount is optionaltrue | falseboolean


Examples of integration in productfeed template 

Spend deposit information as text

First we add a column to the header template of the productfeed

header
[...]
Surcharge{#S#}
[...]
template
[...]
{assign var="output" value=null} 
{foreach $sArticle.mnd_addcharge AS $data}{append 'output' "zzgl. {$data.price|format:"number"} {$sCurrency.currency} {$data.display_name}"}{/foreach} 
{", "|implode:$output}{#S#} 
[...]

Result:

Ergebnis
plus 0,25 EUR Test surcharge, plus 3,21 EUR Second Test Surcharge

Explanation:

{assign var="output" value=null}
We create a variable which we assign values to.
{foreach $addChargeData AS $data}{append 'output' "zzgl. {$data.price|format:"number"} {$sCurrency.currency} {$data.display_name}"}{/foreach}
Then we loop through all available surcharges/discounts and save the info to the "output" array.
{$data.price|format:"number"} 
this makes sure the prices are correctly formatted
{", "|implode:$output}
Finally, we output the surcharges/discount separated by comma.


It is also possible to filter the result by using the surcharge/discount type.

For this, you simply add an if-statment.


template
[...]
{foreach $addChargeData AS $data}
{if $data.type == 'basket'}
	This article contains a surcharge per basket.
    {break}
{/if}
{/foreach}
[...]



Add price of surcharge/discount to article price

header
[...]
Price incl Surcharge{#S#}
{/strip}{#L#}
template
[...]
{assign var="priceIncl" value=$sArticle.price}
{foreach $addChargeData AS $data}{assign var="priceIncl" value=$priceIncl+$data.price}{/foreach}
{$priceIncl}


Result:

Ergebnis
123.41
{assign var="priceIncl" value=$sArticle.price}
We create a smarty variable and assign the price of the article to it
{foreach $addChargeData AS $data}{assign var="priceIncl" value=$priceIncl+$data.price}{/foreach}
Now we loop through every available surcharge/discount and add the price to our variable
{$priceIncl}
Finally, we output the price as float value (without any formatting in this case).