本文整理汇总了C#中Nop.Core.Domain.Customers.Customer.IsSearchEngineAccount方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.IsSearchEngineAccount方法的具体用法?C# Customer.IsSearchEngineAccount怎么用?C# Customer.IsSearchEngineAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Core.Domain.Customers.Customer
的用法示例。
在下文中一共展示了Customer.IsSearchEngineAccount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddToCart
/// <summary>
/// Add a product to shopping cart
/// </summary>
/// <param name="customer">Customer</param>
/// <param name="product">Product</param>
/// <param name="shoppingCartType">Shopping cart type</param>
/// <param name="storeId">Store identifier</param>
/// <param name="attributesXml">Attributes in XML format</param>
/// <param name="customerEnteredPrice">The price enter by a customer</param>
/// <param name="rentalStartDate">Rental start date</param>
/// <param name="rentalEndDate">Rental end date</param>
/// <param name="quantity">Quantity</param>
/// <param name="automaticallyAddRequiredProductsIfEnabled">Automatically add required products if enabled</param>
/// <returns>Warnings</returns>
public virtual IList<string> AddToCart(Customer customer, Product product,
ShoppingCartType shoppingCartType, int storeId, string attributesXml = null,
decimal customerEnteredPrice = decimal.Zero,
DateTime? rentalStartDate = null, DateTime? rentalEndDate = null,
int quantity = 1, bool automaticallyAddRequiredProductsIfEnabled = true)
{
if (customer == null)
throw new ArgumentNullException("customer");
if (product == null)
throw new ArgumentNullException("product");
var warnings = new List<string>();
if (shoppingCartType == ShoppingCartType.ShoppingCart && !_permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart, customer))
{
warnings.Add("Shopping cart is disabled");
return warnings;
}
if (shoppingCartType == ShoppingCartType.Wishlist && !_permissionService.Authorize(StandardPermissionProvider.EnableWishlist, customer))
{
warnings.Add("Wishlist is disabled");
return warnings;
}
if (customer.IsSearchEngineAccount())
{
warnings.Add("Search engine can't add to cart");
return warnings;
}
if (quantity <= 0)
{
warnings.Add(_localizationService.GetResource("ShoppingCart.QuantityShouldPositive"));
return warnings;
}
//reset checkout info
_customerService.ResetCheckoutData(customer, storeId);
var cart = customer.ShoppingCartItems
.Where(sci => sci.ShoppingCartType == shoppingCartType)
.LimitPerStore(storeId)
.ToList();
var shoppingCartItem = FindShoppingCartItemInTheCart(cart,
shoppingCartType, product, attributesXml, customerEnteredPrice,
rentalStartDate, rentalEndDate);
if (shoppingCartItem != null)
{
//update existing shopping cart item
int newQuantity = shoppingCartItem.Quantity + quantity;
warnings.AddRange(GetShoppingCartItemWarnings(customer, shoppingCartType, product,
storeId, attributesXml,
customerEnteredPrice, rentalStartDate, rentalEndDate,
newQuantity, automaticallyAddRequiredProductsIfEnabled));
if (warnings.Count == 0)
{
shoppingCartItem.AttributesXml = attributesXml;
shoppingCartItem.Quantity = newQuantity;
shoppingCartItem.UpdatedOnUtc = DateTime.UtcNow;
_customerService.UpdateCustomer(customer);
//event notification
_eventPublisher.EntityUpdated(shoppingCartItem);
}
}
else
{
//new shopping cart item
warnings.AddRange(GetShoppingCartItemWarnings(customer, shoppingCartType, product,
storeId, attributesXml, customerEnteredPrice,
rentalStartDate, rentalEndDate,
quantity, automaticallyAddRequiredProductsIfEnabled));
if (warnings.Count == 0)
{
//maximum items validation
switch (shoppingCartType)
{
case ShoppingCartType.ShoppingCart:
{
if (cart.Count >= _shoppingCartSettings.MaximumShoppingCartItems)
{
warnings.Add(string.Format(_localizationService.GetResource("ShoppingCart.MaximumShoppingCartItems"), _shoppingCartSettings.MaximumShoppingCartItems));
return warnings;
}
//.........这里部分代码省略.........