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:
Variable | Description | Example | Type | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name | The "Internal Name" of the surcharge/discount. | cansdeposit_1 | string | ||||||||||||
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.25 | float | ||||||||||||
tax | The tax rate of the deposit/discount. | 19.00 | float | ||||||||||||
type | Surcharge type. There are three types.
| multi | single | basket | string | ||||||||||||
optional | shows if a surcharge/discount is optional | true | false | boolean |
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).