当前位置: 首页>>代码示例>>C#>>正文


C# IShoppingCartService.SetProperty方法代码示例

本文整理汇总了C#中IShoppingCartService.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IShoppingCartService.SetProperty方法的具体用法?C# IShoppingCartService.SetProperty怎么用?C# IShoppingCartService.SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IShoppingCartService的用法示例。


在下文中一共展示了IShoppingCartService.SetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:27,代码来源:LocationResolver.cs

示例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;
                }
            }
        }
开发者ID:rtpHarry,项目名称:OShop,代码行数:38,代码来源:CustomerResolver.cs


注:本文中的IShoppingCartService.SetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。