v3.4.x Use in the shopware productfeeds

v3.4.x 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

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.

Description

Keyword

Calculation

surcharge/discount quantity equals article quantity

multi

article quantity 10 = 10x surcharge/discount

Only one per article

single

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

Only one per basket

basket

One surcharge/discount per basket. Surcharge/discount will only be factored 1x per shopping cart. Regardless of number of articles and resp. quantity.

multi | single | basket

string

optional

shows if a surcharge/discount is optional

true | false

boolean



1.1.1. Examples of integration in productfeed template 

1.1.1.1. Spend deposit information as text

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

1.1.1.1.1. header
[...] Surcharge{#S#} [...]
1.1.1.1.2. 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:

1.1.1.1.3. 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.



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





1.1.1.2. Add price of surcharge/discount to article price

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



Result:

1.1.1.2.3. 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).