本文整理汇总了C#中IShoppingCartService.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IShoppingCartService.GetProperty方法的具体用法?C# IShoppingCartService.GetProperty怎么用?C# IShoppingCartService.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShoppingCartService
的用法示例。
在下文中一共展示了IShoppingCartService.GetProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCart
public void BuildCart(IShoppingCartService ShoppingCartService, ShoppingCart Cart)
{
LocationsStateRecord state = null;
LocationsCountryRecord country = null;
// Based on user selected location
Int32 countryId = ShoppingCartService.GetProperty<int>("CountryId");
if (countryId > 0) {
country = _locationsService.GetCountry(countryId);
Int32 stateId = ShoppingCartService.GetProperty<int>("StateId");
if (stateId > 0) {
state = _locationsService.GetState(stateId);
}
}
else {
// Set default country
country = _locationsService.GetDefaultCountry();
if (country != null) {
ShoppingCartService.SetProperty<int>("CountryId", country.Id);
}
}
Cart.Properties["BillingCountry"] = country;
Cart.Properties["BillingState"] = state;
Cart.Properties["ShippingCountry"] = country;
Cart.Properties["ShippingState"] = state;
}
示例2: BuildCart
public void BuildCart(IShoppingCartService ShoppingCartService, ShoppingCart Cart)
{
var customer = _customersService.GetCustomer();
if (customer == null) {
return;
}
// Get "Checkout" property to know the Checkout provider beeing used
var checkout = ShoppingCartService.GetProperty<string>("Checkout");
if (string.IsNullOrWhiteSpace(checkout) && customer.DefaultAddress != null) {
// Override default location
ShoppingCartService.SetProperty<int>("CountryId", customer.DefaultAddress.CountryId);
ShoppingCartService.SetProperty<int>("StateId", customer.DefaultAddress.StateId);
Cart.Properties["BillingCountry"] = customer.DefaultAddress.Country;
Cart.Properties["BillingState"] = customer.DefaultAddress.State;
Cart.Properties["ShippingCountry"] = customer.DefaultAddress.Country;
Cart.Properties["ShippingState"] = customer.DefaultAddress.State;
}
else if (checkout == "Checkout") {
var billingAddress = customer.Addresses.Where(a => a.Id == ShoppingCartService.GetProperty<int>("BillingAddressId")).FirstOrDefault() ?? customer.DefaultAddress ?? customer.Addresses.FirstOrDefault();
var shippingAddress = customer.Addresses.Where(a => a.Id == ShoppingCartService.GetProperty<int>("ShippingAddressId")).FirstOrDefault() ?? customer.DefaultAddress ?? customer.Addresses.FirstOrDefault();
if (billingAddress != null) {
Cart.Properties["BillingAddress"] = billingAddress;
Cart.Properties["BillingCountry"] = billingAddress.Country;
Cart.Properties["BillingState"] = billingAddress.State;
}
if (shippingAddress != null) {
Cart.Properties["ShippingAddress"] = shippingAddress;
Cart.Properties["ShippingCountry"] = shippingAddress.Country;
Cart.Properties["ShippingState"] = shippingAddress.State;
}
}
}
示例3: BuildCart
public void BuildCart(IShoppingCartService ShoppingCartService, ShoppingCart Cart)
{
if (!Cart.IsShippingRequired()) {
Cart.Shipping = null;
return;
}
var zone = Cart.Properties["ShippingZone"] as ShippingZoneRecord;
if (zone == null) {
// Need a shipping zone
//Cart.InvalidCart();
Cart.Shipping = null;
return;
}
var suitableProviders = _shippingService.GetSuitableProviderOptions(
zone,
Cart.Properties["ShippingInfos"] as IList<Tuple<int, IShippingInfo>> ?? new List<Tuple<int, IShippingInfo>>(),
Cart.ItemsTotal()
);
if (!suitableProviders.Any()) {
// Need a suitable shipping provider
//Cart.InvalidCart();
Cart.Shipping = null;
return;
}
Int32 selectedProviderId = ShoppingCartService.GetProperty<int>("ShippingProviderId");
var selectedProvider = suitableProviders.Where(p => p.Provider.Id == selectedProviderId).FirstOrDefault();
if (selectedProvider != null) {
// Apply selected provider
Cart.Shipping = selectedProvider;
}
else {
// Set cheapest option
Cart.Shipping = suitableProviders.OrderBy(p => p.Option.Price).FirstOrDefault();
}
}
示例4: BuildOrder
public void BuildOrder(IShoppingCartService ShoppingCartService, IContent Order)
{
var customer = _customersService.GetCustomer();
if (customer == null) {
return;
}
OrderAddressRecord billingAddress = null, shippingAddress = null;
Int32 billingAddressId = ShoppingCartService.GetProperty<int>("BillingAddressId");
if (billingAddressId > 0) {
var customerBillingAddress = customer.Addresses.Where(a => a.Id == billingAddressId).FirstOrDefault();
if (customerBillingAddress != null) {
billingAddress = new OrderAddressRecord();
customerBillingAddress.CopyTo(billingAddress);
}
}
Int32 shippingAddressId = ShoppingCartService.GetProperty<int>("ShippingAddressId");
if (shippingAddressId > 0) {
if (shippingAddressId == billingAddressId) {
shippingAddress = billingAddress;
}
else {
var customerShippingAddress = customer.Addresses.Where(a => a.Id == shippingAddressId).FirstOrDefault();
if (customerShippingAddress != null) {
shippingAddress = new OrderAddressRecord();
customerShippingAddress.CopyTo(shippingAddress);
}
}
}
var customerOrderPart = Order.As<CustomerOrderPart>();
if (customerOrderPart != null) {
customerOrderPart.Customer = customer;
}
var orderPart = Order.As<OrderPart>();
if (orderPart != null && billingAddress != null) {
orderPart.BillingAddress = billingAddress;
}
var shippingPart = Order.As<OrderShippingPart>();
if (shippingPart != null) {
// Shipping address
if (shippingAddress != null) {
// Set address
shippingPart.ShippingAddress = shippingAddress;
// Set shipping zone
var workContext = _workContextAccessor.GetContext();
if (shippingAddress.State != null && shippingAddress.State.Enabled && shippingAddress.State.ShippingZoneRecord != null) {
workContext.SetState("OShop.Orders.ShippingZone", shippingAddress.State.ShippingZoneRecord);
}
else if (shippingAddress.Country != null && shippingAddress.Country.Enabled && shippingAddress.Country.ShippingZoneRecord != null) {
workContext.SetState("OShop.Orders.ShippingZone", shippingAddress.Country.ShippingZoneRecord);
}
}
}
}
示例5: BuildOrder
public void BuildOrder(IShoppingCartService ShoppingCartService, IContent Order)
{
var orderPart = Order.As<OrderPart>();
var shippingPart = Order.As<OrderShippingPart>();
if (orderPart != null && shippingPart != null) {
// Shipping option
var workContext = _workContextAccessor.GetContext();
var shippingInfos = workContext.GetState<IList<Tuple<int, IShippingInfo>>>("OShop.Orders.ShippingInfos");
if (!shippingInfos.IsShippingRequired()) {
shippingPart.ShippingStatus = ShippingStatus.NotRequired;
return;
}
Int32 selectedProviderId = ShoppingCartService.GetProperty<int>("ShippingProviderId");
var suitableProviders = _shippingService.GetSuitableProviderOptions(
workContext.GetState<ShippingZoneRecord>("OShop.Orders.ShippingZone"),
workContext.GetState<IList<Tuple<int, IShippingInfo>>>("OShop.Orders.ShippingInfos") ?? new List<Tuple<int, IShippingInfo>>(),
orderPart.Details.Sum(d => d.Total)
);
var selectedOption = suitableProviders.Where(po => po.Provider.Id == selectedProviderId).FirstOrDefault();
if (selectedOption != null) {
orderPart.Details.Add(new OrderDetail("Shipping") {
ContentId = selectedOption.Id,
Designation = selectedOption.Provider.As<ITitleAspect>().Title,
Description = selectedOption.Option.Name,
UnitPrice = selectedOption.Price,
Quantity = 1
});
shippingPart.ShippingStatus = ShippingStatus.Pending;
}
}
}