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