Table of Contents

Class SetAmountFromProductAsFinalPriceExtender

Namespace
Dynamicweb.Ecommerce.Orders.Discounts
Assembly
Dynamicweb.Ecommerce.dll
public class SetAmountFromProductAsFinalPriceExtender : DiscountExtenderBase, IDiscountExtenderCalculateProductDiscount
Inheritance
SetAmountFromProductAsFinalPriceExtender
Implements
Inherited Members

Properties

CalculateDiscountToReachSpecifiedDiscountPrice

[AddInParameter("Set price with discount to amount field")]
[AddInDescription("Will set the final discounted price of a product to the value specified on the product custom field.")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "")]
public bool CalculateDiscountToReachSpecifiedDiscountPrice { get; set; }

Property Value

bool

Methods

DiscountValidForOrder(Order)

Determines if discount is valid for given order.
public override bool DiscountValidForOrder(Order order)

Parameters

order Order
The order to conduct the check for.

Returns

bool
true if discount is valid for the specified order; otherwise, false.

Examples

  using Dynamicweb.Ecommerce.Orders;
                                                                                                                                                                                                                                             using Dynamicweb.Ecommerce.Orders.Discounts;
                                                                                                                                                                                                                                             using Dynamicweb.Extensibility.AddIns;
                                                                                                                                                                                                                                             using Dynamicweb.Extensibility.Editors;

                                                                                                                                                                                                                                             namespace Dynamicweb.Ecommerce.Examples.Orders.Discounts
                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                 /// <summary>
                                                                                                                                                                                                                                                 /// The example of an extender for order discounts
                                                                                                                                                                                                                                                 /// </summary>
                                                                                                                                                                                                                                                 public class FavoriteNameDiscountExtender : DiscountExtenderBase
                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                     [AddInParameter("Favorite name"), AddInDescription("Specify what a customer name should start with to get this discount"), AddInParameterEditor(typeof(TextParameterEditor), "")]
                                                                                                                                                                                                                                                     public string FavoriteName { get; set; }

                                                                                                                                                                                                                                                     /// <summary>
                                                                                                                                                                                                                                                     /// Constructor - sets the favorite name to Marta
                                                                                                                                                                                                                                                     /// </summary>
                                                                                                                                                                                                                                                     public FavoriteNameDiscountExtender()
                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                         FavoriteName = "Marta";
                                                                                                                                                                                                                                                     }

                                                                                                                                                                                                                                                     /// <summary>
                                                                                                                                                                                                                                                     /// If this extender is used for an order discount, it will be checked here
                                                                                                                                                                                                                                                     /// Checks if the name on the order starts with the specified name and returns true to apply the discount
                                                                                                                                                                                                                                                     /// </summary>
                                                                                                                                                                                                                                                     public override bool DiscountValidForOrder(Order order)
                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                         var valid = false;

                                                                                                                                                                                                                                                         if (!string.IsNullOrEmpty(FavoriteName) && !string.IsNullOrEmpty(order.CustomerName))
                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                             valid = order.CustomerName.StartsWith(FavoriteName, System.StringComparison.OrdinalIgnoreCase);
                                                                                                                                                                                                                                                         }

                                                                                                                                                                                                                                                         return valid;
                                                                                                                                                                                                                                                     }


                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                             }

DiscountValidForProduct(Product)

Determines if discount is valid for given product.
public override bool DiscountValidForProduct(Product product)

Parameters

product Product
The product to conduct the check for.

Returns

bool
true if discount is valid for the specified product; otherwise, false.

Examples

  using Dynamicweb.Ecommerce.Products;
                                                                                                                                                                                                                                                   using Dynamicweb.Ecommerce.Orders.Discounts;
                                                                                                                                                                                                                                                   using Dynamicweb.Extensibility.AddIns;
                                                                                                                                                                                                                                                   using Dynamicweb.Extensibility.Editors;

                                                                                                                                                                                                                                                   namespace Dynamicweb.Ecommerce.Examples.Orders.Discounts
                                                                                                                                                                                                                                                   {
                                                                                                                                                                                                                                                       /// <summary>
                                                                                                                                                                                                                                                       /// The example of an extender for product discounts - if applied the discount will be valid for products with a price less than specified
                                                                                                                                                                                                                                                       /// </summary>
                                                                                                                                                                                                                                                       public class CheapProductsDiscountExtender : DiscountExtenderBase
                                                                                                                                                                                                                                                       {

                                                                                                                                                                                                                                                           [AddInParameter("Cheap price"), AddInDescription("Specify max price a product should have to get the discount"), AddInParameterEditor(typeof(IntegerNumberParameterEditor), "minValue=0;maxValue=1000;allowNegativeValues=false;localizeValues=true;")]
                                                                                                                                                                                                                                                           public int CheapPrice { get; set; }

                                                                                                                                                                                                                                                           /// <summary>
                                                                                                                                                                                                                                                           /// Constructor - sets the maximum price to 100
                                                                                                                                                                                                                                                           /// </summary>
                                                                                                                                                                                                                                                           public CheapProductsDiscountExtender()
                                                                                                                                                                                                                                                           {
                                                                                                                                                                                                                                                               CheapPrice = 100;
                                                                                                                                                                                                                                                           }

                                                                                                                                                                                                                                                           /// <summary>
                                                                                                                                                                                                                                                           /// If this extender is used for a product discount, it will be checked here
                                                                                                                                                                                                                                                           /// </summary>
                                                                                                                                                                                                                                                           public override bool DiscountValidForProduct(Product product)
                                                                                                                                                                                                                                                           {
                                                                                                                                                                                                                                                               return product.DefaultPrice <= CheapPrice;
                                                                                                                                                                                                                                                           }

                                                                                                                                                                                                                                                       }
                                                                                                                                                                                                                                                   }

GetDiscount(Product, Currency, Country)

Return the discount amount as a priceinfo that should be given to the passed product
public PriceInfo GetDiscount(Product product, Currency currency, Country country)

Parameters

product Product
The product to calculate the discount for
currency Currency
country Country

Returns

PriceInfo
The amount that is wanted to be given in discount
To top