Try our conversational search powered by Generative AI!

Add Co2 compensation fee in checkout

Vote:
 

Hi guys!

I am going to implment a Co2 compensation fee feature in a Episerver Commerce project.

In checkout page, customer can choose to pay a optinal Co2 compensation fee based on the total weight of the products. 

If the customer choose to pay this fee, it needs to be a part of the total cost in purchase order.

What is the best way to implment this feature? Any suggestions?

Thanks,

ChiChing

#217724
Feb 28, 2020 8:34
Vote:
 

There are atleast two viable way to do it and it depends a bit on which other integrations you have and how that fee is based on the total weight:

  1. Create a special dummy VariationContent and use it as a placeholder LineItem. This way the total are calculated correctly without any extra work and it is often more easier to integrate with payment solutions and other systems. It will however require some work to exclude the lineitem from promotions.
  2. Add the fee in custom fields on the OrderForm. You have to implement your own IOrderFormCalculator for this as well as ITaxCalculator since you probably have to pay Vat on the fee too.

In either case extra work have to be taken to keep the fee updated whenever the total weight changes.

#217743
Feb 28, 2020 15:56
ChiChing Lam - Mar 05, 2020 7:45
Thank for your suggestion! :)
I will try the first alternative.
Vote:
 

I don't know why it "requires some work to exclude the lineitem from promotions.", it should be super easy and simple as

entryFilterSettings.AddFilter(x=>x.IsExcluded);

entryFilterSettings is an instance of EntryFilterSettings which can be retrieved by constructor injection 

#217832
Mar 02, 2020 9:30
Vote:
 

Correct, slipped my mind, it is what i get for doing things on friday afternoon. :)

entryFilterSettings.AddFilter<Co2CompensationVariationContent>(x => false);

Would definately do the job, more info and full example here: https://world.episerver.com/documentation/developer-guides/commerce/marketing/exclude-products-from-promotions/

The extra work with having it as a lineitem will have more to do with how that lineitem will be displayed on the site as it probably shouldn't look like a normal lineitem.

#217875
Mar 02, 2020 16:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.