Surcharge for Multiple Manufacturers

A simple concept, with a tricky Count expression :)   We count distinct manufacturers for all the products in the cart.  The base shipping rate is 10.00 (includes up to one manufacturer), and then 3.00 extra surcharge for each manufacturer beyond the first.

Order

Type

Name

Expression

Rate Expression

Surcharge Expression

10

Integer

ManufacturerCount

Items.Select(Product.ProductManufacturers.Any() ? Product.ProductManufacturers.First().Manufacturer.Name : "").Distinct().Count() -1

 

 

20

Decimal

Surcharge

[ManufacturerCount] <= 1 ? 0 : [ManufacturerCount] * 3.00

 

 

100

Option

Shipping

true

10.00

[Surcharge]

Note, that in nopCommerce, Products can have more than one manufacturer, so we only get its first one.  The " -1 " compensates for those products that don't have any manufacturer.  (You can remove that if you want to also count for "the store").  If you want to surcharge even for the first manufacturer, then  change the Surcharge expression to just  [ManufacturerCount] * 3.00

You can download the above configuration that you can then import into Shipping Director.

Tags :  Manufacturer Fee
Comments
Leave your comment
:
info@promsys.no
Created on: 12/4/2014 10:25 AM
Hi

Great work!

It seems like it adds one to the count if it does not have a manufacturer. I think it is the …. : "") this adds one to the list.

Is there a way to get around this? We really need to
not add manufacturershipping to certain products.  

Is there a way to exclude some Manufacturers.

Best regards
Vidar, PromSys
support@nopTools.com
Created on: 12/4/2014 10:02 PM
The idea was that you can't use First(). ... if the list is empty, or it would throw an error.  It can be written another way:

Items.Any(!Product.ProductManufacturers.Any()) ? 0 : Items.Select(Product.ProductManufacturers.First().Manufacturer.Name).Distinct().Count()

You can filter out certain manufacturers like this

Product.ProductManufacturers.Where(Manufacturer.Name = "...")

Use the Contact Use form if you need more info.
m.iannilli@aretek.it
Created on: 5/11/2018 11:16 AM
Hi. i try to use this

Items.Any(!Product.ProductManufacturers.Any()) ? 0 : Items.Select(Product.ProductManufacturers.First().Manufacturer.Name).Distinct().Count()


But it returns 0 Manufacturer: in cart i have 3 products, one from one manufacturer and two from another.

What's the problem?
support@nopTools.com
Created on: 5/12/2018 8:41 AM
That should work fine.  What version of nopCommerce are you using? You can use
0   $Debug true  
and check the system log to see the tracing.
Or, put in a line
15 OptionExit    ShowCount      [ManufacturerCount]
and use the TEST button to see the result on the config page.

contact us at support@nopTools.com if still having problems
sample@email.tst
Created on: 6/26/2023 5:32 PM
1