本文整理汇总了C#中SmartStore.Core.Domain.Catalog.Product.ParseAllowedQuatities方法的典型用法代码示例。如果您正苦于以下问题:C# Product.ParseAllowedQuatities方法的具体用法?C# Product.ParseAllowedQuatities怎么用?C# Product.ParseAllowedQuatities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartStore.Core.Domain.Catalog.Product
的用法示例。
在下文中一共展示了Product.ParseAllowedQuatities方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_parse_allowed_quantities
public void Can_parse_allowed_quantities()
{
var product = new Product()
{
AllowedQuantities = "1, 5,4,10,sdf"
};
var result = product.ParseAllowedQuatities();
result.Length.ShouldEqual(4);
result[0].ShouldEqual(1);
result[1].ShouldEqual(5);
result[2].ShouldEqual(4);
result[3].ShouldEqual(10);
}
示例2: GetStandardWarnings
//.........这里部分代码省略.........
//call for price
if (shoppingCartType == ShoppingCartType.ShoppingCart && product.CallForPrice)
{
warnings.Add(_localizationService.GetResource("Products.CallForPrice"));
}
//customer entered price
if (product.CustomerEntersPrice)
{
if (customerEnteredPrice < product.MinimumCustomerEnteredPrice ||
customerEnteredPrice > product.MaximumCustomerEnteredPrice)
{
decimal minimumCustomerEnteredPrice = _currencyService.ConvertFromPrimaryStoreCurrency(product.MinimumCustomerEnteredPrice, _workContext.WorkingCurrency);
decimal maximumCustomerEnteredPrice = _currencyService.ConvertFromPrimaryStoreCurrency(product.MaximumCustomerEnteredPrice, _workContext.WorkingCurrency);
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.CustomerEnteredPrice.RangeError"),
_priceFormatter.FormatPrice(minimumCustomerEnteredPrice, false, false),
_priceFormatter.FormatPrice(maximumCustomerEnteredPrice, false, false)));
}
}
//quantity validation
var hasQtyWarnings = false;
if (quantity < product.OrderMinimumQuantity)
{
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.MinimumQuantity"), product.OrderMinimumQuantity));
hasQtyWarnings = true;
}
if (quantity > product.OrderMaximumQuantity)
{
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.MaximumQuantity"), product.OrderMaximumQuantity));
hasQtyWarnings = true;
}
var allowedQuantities = product.ParseAllowedQuatities();
if (allowedQuantities.Length > 0 && !allowedQuantities.Contains(quantity))
{
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.AllowedQuantities"), string.Join(", ", allowedQuantities)));
}
var validateOutOfStock = shoppingCartType == ShoppingCartType.ShoppingCart || !_shoppingCartSettings.AllowOutOfStockItemsToBeAddedToWishlist;
if (validateOutOfStock && !hasQtyWarnings)
{
switch (product.ManageInventoryMethod)
{
case ManageInventoryMethod.DontManageStock:
{
}
break;
case ManageInventoryMethod.ManageStock:
{
if ((BackorderMode)product.BackorderMode == BackorderMode.NoBackorders)
{
if (product.StockQuantity < quantity)
{
int maximumQuantityCanBeAdded = product.StockQuantity;
if (maximumQuantityCanBeAdded <= 0)
warnings.Add(_localizationService.GetResource("ShoppingCart.OutOfStock"));
else
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.QuantityExceedsStock"), maximumQuantityCanBeAdded));
}
}
}
break;
case ManageInventoryMethod.ManageStockByAttributes:
{
var combination = product
示例3: PrepareProductDetailModel
//.........这里部分代码省略.........
model.BasePriceInfo = product.GetBasePriceInfo(
_localizationService,
_priceFormatter,
_currencyService,
_taxService,
_priceCalculationService,
currency,
attributesTotalPriceBase);
if (!string.IsNullOrWhiteSpace(model.ProductPrice.OldPrice) || !string.IsNullOrWhiteSpace(model.ProductPrice.PriceWithDiscount))
{
model.ProductPrice.NoteWithoutDiscount = T(isBundle && product.BundlePerItemPricing ? "Products.Bundle.PriceWithoutDiscount.Note" : "Products.Price");
}
if ((isBundle && product.BundlePerItemPricing && !string.IsNullOrWhiteSpace(model.ProductPrice.PriceWithDiscount)) || product.HasTierPrices)
{
if (!product.HasTierPrices)
{
model.ProductPrice.NoteWithDiscount = T("Products.Bundle.PriceWithDiscount.Note");
}
model.BasePriceInfo = product.GetBasePriceInfo(
_localizationService,
_priceFormatter,
_currencyService,
_taxService,
_priceCalculationService,
currency,
(product.Price - finalPriceWithDiscount) * (-1));
}
}
}
}
else
{
model.ProductPrice.HidePrices = true;
model.ProductPrice.OldPrice = null;
model.ProductPrice.Price = null;
}
#endregion
#region 'Add to cart' model
model.AddToCart.ProductId = product.Id;
//quantity
model.AddToCart.EnteredQuantity = product.OrderMinimumQuantity;
//'add to cart', 'add to wishlist' buttons
model.AddToCart.DisableBuyButton = product.DisableBuyButton || !_services.Permissions.Authorize(StandardPermissionProvider.EnableShoppingCart);
model.AddToCart.DisableWishlistButton = product.DisableWishlistButton || !_services.Permissions.Authorize(StandardPermissionProvider.EnableWishlist);
if (!displayPrices)
{
model.AddToCart.DisableBuyButton = true;
model.AddToCart.DisableWishlistButton = true;
}
//pre-order
model.AddToCart.AvailableForPreOrder = product.AvailableForPreOrder;
//customer entered price
model.AddToCart.CustomerEntersPrice = product.CustomerEntersPrice;
if (model.AddToCart.CustomerEntersPrice)
{
var minimumCustomerEnteredPrice = _currencyService.ConvertFromPrimaryStoreCurrency(product.MinimumCustomerEnteredPrice, currency);
var maximumCustomerEnteredPrice = _currencyService.ConvertFromPrimaryStoreCurrency(product.MaximumCustomerEnteredPrice, currency);
model.AddToCart.CustomerEnteredPrice = minimumCustomerEnteredPrice;
model.AddToCart.CustomerEnteredPriceRange = string.Format(T("Products.EnterProductPrice.Range"),
_priceFormatter.FormatPrice(minimumCustomerEnteredPrice, true, false),
_priceFormatter.FormatPrice(maximumCustomerEnteredPrice, true, false));
}
//allowed quantities
var allowedQuantities = product.ParseAllowedQuatities();
foreach (var qty in allowedQuantities)
{
model.AddToCart.AllowedQuantities.Add(new SelectListItem
{
Text = qty.ToString(),
Value = qty.ToString()
});
}
#endregion
#region Gift card
model.GiftCard.IsGiftCard = product.IsGiftCard;
if (model.GiftCard.IsGiftCard)
{
model.GiftCard.GiftCardType = product.GiftCardType;
model.GiftCard.SenderName = customer.GetFullName();
model.GiftCard.SenderEmail = customer.Email;
}
#endregion
return model;
}