| ProductProviderBaseGetPrice Method |
Gets the price.
Namespace:
Dynamicweb.Ecommerce.LiveIntegration.Products
Assembly:
Dynamicweb.Ecommerce.LiveIntegration (in Dynamicweb.Ecommerce.LiveIntegration.dll) Version: 3.0.1
Syntax public virtual Nullable<double> GetPrice(
ProductInfo product,
double quantity
)
Public Overridable Function GetPrice (
product As ProductInfo,
quantity As Double
) As Nullable(Of Double)
Parameters
- product
- Type: Dynamicweb.Ecommerce.IntegrationProductInfo
The product. - quantity
- Type: SystemDouble
The quantity.
Return Value
Type:
NullableDoubleSystem.Nullable<System.Double>.
Exceptions Examples using Dynamicweb.Ecommerce.Integration;
using Dynamicweb.Ecommerce.Products;
namespace Dynamicweb.Ecommerce.LiveIntegration.Examples
{
public class CustomProductProvider : Products.ProductProviderBase
{
public override string GetProductIdentifier(Product product)
{
return GetProductIdentifier(product, null);
}
public override string GetProductIdentifier(Product product, string unitId)
{
string unit = string.IsNullOrEmpty(unitId) ? string.Empty : $"-{unitId}";
return $"{product.Id}-{product.VariantId}-{product.LanguageId}-{product.Number}{unit}";
}
public override double? GetPrice(ProductInfo product, double quantity)
{
double unitPrice;
if(double.TryParse(product["TotalPrice"].ToString(), out unitPrice))
{
return unitPrice * quantity;
}
else
{
return base.GetPrice(product, quantity);
}
}
}
}
See Also