本文整理汇总了C#中MerchantTribe.Commerce.Orders.Order类的典型用法代码示例。如果您正苦于以下问题:C# Order类的具体用法?C# Order怎么用?C# Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Order类属于MerchantTribe.Commerce.Orders命名空间,在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadOrder
private void LoadOrder()
{
o = MTApp.OrderServices.Orders.FindForCurrentStore(Request.QueryString["id"]);
if (o != null)
{
this.lblOrderNumber.Text = "Order " + o.OrderNumber + " ";
this.ShippingAddressField.Text = o.ShippingAddress.ToHtmlString();
this.ShippingTotalLabel.Text = o.TotalShippingAfterDiscounts.ToString("c");
this.ItemsGridView.DataSource = o.Items;
this.ItemsGridView.DataBind();
this.PackagesGridView.DataSource = o.FindShippedPackages();
this.PackagesGridView.DataBind();
//this.SuggestedPackagesGridView.DataSource = o.FindSuggestedPackages();
//this.SuggestedPackagesGridView.DataBind();
this.UserSelectedShippingMethod.Text = "User Selected Shipping Method: <b>" + o.ShippingMethodDisplayName + "</b>";
//if (this.lstShippingProvider.Items.FindByValue(o.ShippingProviderId) != null) {
// this.lstShippingProvider.ClearSelection();
// this.lstShippingProvider.Items.FindByValue(o.ShippingProviderId).Selected = true;
// LoadServiceCodes();
// this.lstServiceCode.SelectedValue = o.ShippingProviderServiceCode;
//}
}
}
示例2: CanAddItemToOrderAndCalculate
public void CanAddItemToOrderAndCalculate()
{
RequestContext c = new RequestContext();
MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
c.CurrentStore = new Accounts.Store();
c.CurrentStore.Id = 1;
Order target = new Order();
LineItem li = new LineItem() { BasePricePerItem = 19.99m,
ProductName = "Sample Product",
ProductSku = "ABC123",
Quantity = 2 };
target.Items.Add(li);
app.CalculateOrder(target);
Assert.AreEqual(39.98m, target.TotalOrderBeforeDiscounts, "SubTotal was Incorrect");
Assert.AreEqual(39.98m, target.TotalGrand, "Grand Total was incorrect");
bool upsertResult = app.OrderServices.Orders.Upsert(target);
Assert.IsTrue(upsertResult, "Order Upsert Failed");
Assert.AreEqual(c.CurrentStore.Id, target.StoreId, "Order store ID was not set correctly");
Assert.AreNotEqual(string.Empty, target.bvin, "Order failed to get a bvin");
Assert.AreEqual(1, target.Items.Count, "Item count should be one");
Assert.AreEqual(target.bvin, target.Items[0].OrderBvin, "Line item didn't receive order bvin");
Assert.AreEqual(target.StoreId, target.Items[0].StoreId, "Line item didn't recieve storeid");
}
示例3: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Tag an id to the querystring to support back button
if (Request.QueryString["id"] != null)
{
this.BvinField.Value = Request.QueryString["id"];
}
else
{
o = new Order();
MTApp.OrderServices.Orders.Create(o);
Response.Redirect("CreateOrder.aspx?id=" + o.bvin);
}
if (this.BvinField.Value.Trim() != string.Empty)
{
o = MTApp.OrderServices.Orders.FindForCurrentStore(this.BvinField.Value);
}
if (!Page.IsPostBack)
{
LoadOrder();
LoadPaymentMethods();
LoadCurrentUser();
}
//Me.UserPicker1.MessageBox = MessageBox1
//AddHandler Me.UserPicker1.UserSelected, AddressOf Me.UserSelected
//If Me.NewSkuField.Text <> String.Empty Then
//VariantsDisplay1.Initialize(False)
//End If
}
示例4: OrderPaymentManager
public OrderPaymentManager(Order ord, MerchantTribeApplication app)
{
o = ord;
this.MTApp = app;
svc = MTApp.OrderServices;
this.contacts = this.MTApp.ContactServices;
this.content = this.MTApp.ContentServices;
Accounts.Store CurrentStore = app.CurrentRequestContext.CurrentStore;
pointsManager = CustomerPointsManager.InstantiateForDatabase(CurrentStore.Settings.RewardsPointsIssuedPerDollarSpent,
CurrentStore.Settings.RewardsPointsNeededPerDollarCredit,
app.CurrentRequestContext.CurrentStore.Id);
}
示例5: ReloadOrder
private void ReloadOrder(OrderShippingStatus previousShippingStatus)
{
o = MTApp.OrderServices.Orders.FindForCurrentStore(Request.QueryString["id"]);
o.EvaluateCurrentShippingStatus();
MTApp.OrderServices.Orders.Update(o);
MerchantTribe.Commerce.BusinessRules.OrderTaskContext context
= new MerchantTribe.Commerce.BusinessRules.OrderTaskContext(MTApp);
context.Order = o;
context.UserId = o.UserID;
context.Inputs.Add("bvsoftware", "PreviousShippingStatus", previousShippingStatus.ToString());
MerchantTribe.Commerce.BusinessRules.Workflow.RunByName(context, MerchantTribe.Commerce.BusinessRules.WorkflowNames.ShippingChanged);
LoadOrder();
this.OrderStatusDisplay1.LoadStatusForOrder(o);
}
示例6: Calculate
public bool Calculate(Order o)
{
// reset values
o.TotalShippingBeforeDiscounts = 0;
o.TotalTax = 0;
o.TotalTax2 = 0;
o.TotalHandling = 0;
o.ClearDiscounts();
if (!SkipRepricing)
{
// Price items for current user
RepriceItemsForUser(o);
}
// Discount prices for volume ordered
ApplyVolumeDiscounts(o);
//Apply Offers to Line Items and Sub Total
ApplyOffersToOrder(o, PromotionActionMode.ForLineItems);
ApplyOffersToOrder(o, PromotionActionMode.ForSubTotal);
// Calculate Handling, Merge with Shipping For Display
o.TotalHandling = CalculateHandlingAmount(o);
OrdersCalculateShipping(o);
// Calculate Per Item shipping and handling portion
//CalculateShippingPortion(o);
// Apply shipping offers
ApplyOffersToOrder(o, PromotionActionMode.ForShipping);
// Calcaulte Taxes
o.ClearTaxes();
List<Taxes.ITaxSchedule> schedules = _app.OrderServices.TaxSchedules.FindAllAndCreateDefaultAsInterface(o.StoreId);
Contacts.Address destination = o.ShippingAddress;
ApplyTaxes(schedules, o.ItemsAsITaxable(), destination, o);
// Calculate Sub Total of Items
foreach (LineItem li in o.Items)
{
o.TotalTax += li.TaxPortion;
}
return true;
}
示例7: CartViewModel
public CartViewModel()
{
CurrentOrder = new Order();
this.AddCouponButtonUrl = string.Empty;
this.DeleteButtonUrl = string.Empty;
this.KeepShoppingButtonUrl = string.Empty;
this.KeepShoppingUrl = string.Empty;
this.CheckoutButtonUrl = string.Empty;
this.EstimateShippingButtonUrl = string.Empty;
this.DisplayTitle = "Shopping Cart";
this.DisplaySubTitle = string.Empty;
this.ItemListTitle = string.Empty;
this.CartEmpty = false;
this.LineItems = new List<CartLineItemViewModel>();
this.PayPalExpressAvailable = false;
}
示例8: LoadStatusForOrder
public void LoadStatusForOrder(Order o)
{
if (o != null)
{
this.litPay.Text = EnumToString.OrderPaymentStatus(o.PaymentStatus);
this.litShip.Text = EnumToString.OrderShippingStatus(o.ShippingStatus);
if (lstStatus.Items.FindByValue(o.StatusCode) != null)
{
lstStatus.ClearSelection();
lstStatus.Items.FindByValue(o.StatusCode).Selected = true;
}
}
}
示例9: RepriceItemsForUser
private void RepriceItemsForUser(Order o)
{
foreach (LineItem li in o.Items)
{
Catalog.UserSpecificPrice price = _app.PriceProduct(li.ProductId, o.UserID, li.SelectionData);
// Null check because if the item isn't in the catalog
// we will get back a null user specific price.
//
// In the future it may be a good idea to add an option
// allowing merchant to select if they would like to allow
// items not in the catalog to exist in carts or if we should
// just remove items from the cart with a warning here.
if (price != null)
{
li.BasePricePerItem = price.BasePrice;
foreach (Marketing.DiscountDetail discount in price.DiscountDetails)
{
li.DiscountDetails.Add(new Marketing.DiscountDetail() { Amount = discount.Amount * li.Quantity, Description = discount.Description });
}
}
}
}
示例10: OnLoad
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
orderId = Request.QueryString["id"];
o = MyPage.MTApp.OrderServices.Orders.FindForCurrentStore(orderId);
payManager = new OrderPaymentManager(o, MyPage.MTApp);
if (!Page.IsPostBack)
{
this.mvPayments.SetActiveView(this.viewCreditCards);
LoadCreditCardLists();
if (MyPage.MTApp.CurrentStore.PlanId < 2)
{
//this.lnkCash.Visible = false;
this.lnkCheck.Visible = false;
this.lnkPO.Visible = false;
}
}
}
示例11: PostAction
// Create or Update
public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata)
{
string data = string.Empty;
//string bvin = FirstParameter(parameters);
ApiResponse<OrderDTO> response = new ApiResponse<OrderDTO>();
OrderDTO postedItem = null;
try
{
postedItem = MerchantTribe.Web.Json.ObjectFromJson<OrderDTO>(postdata);
}
catch (Exception ex)
{
response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
return MerchantTribe.Web.Json.ObjectToJson(response);
}
Order item = new Order();
item.FromDTO(postedItem);
Order existing = MTApp.OrderServices.Orders.FindForCurrentStore(item.bvin);
if (existing == null || existing.bvin == string.Empty)
{
item.StoreId = MTApp.CurrentStore.Id;
MTApp.OrderServices.Orders.Create(item);
}
else
{
MTApp.OrderServices.Orders.Update(item);
}
Order resultItem = MTApp.OrderServices.Orders.FindForCurrentStore(item.bvin);
if (resultItem != null) response.Content = resultItem.ToDto();
data = MerchantTribe.Web.Json.ObjectToJson(response);
return data;
}
示例12: CalculateHandlingAmount
private decimal CalculateHandlingAmount(Order o)
{
Accounts.Store currentStore = _app.CurrentStore;
if (currentStore == null) return 0;
if (currentStore.Settings.HandlingType == (int)HandlingMode.PerItem)
{
decimal amount = 0;
foreach (Orders.LineItem item in o.Items)
{
if (item.ShippingSchedule == -1)
{
if (currentStore.Settings.HandlingNonShipping)
{
amount += item.Quantity;
}
}
else
{
amount += item.Quantity;
}
}
return (currentStore.Settings.HandlingAmount * amount);
}
else if (currentStore.Settings.HandlingType == (int)HandlingMode.PerOrder)
{
//charge handling if there aren't non shipping items
if (currentStore.Settings.HandlingNonShipping)
{
foreach (Orders.LineItem item in o.Items)
{
return currentStore.Settings.HandlingAmount;
}
}
else
{
foreach (Orders.LineItem item in o.Items)
{
if (item.ShippingSchedule != -1)
{
return currentStore.Settings.HandlingAmount;
}
}
}
}
return 0;
}
示例13: OrdersCalculateShipping
private void OrdersCalculateShipping(Order o)
{
o.TotalShippingBeforeDiscounts = 0;
if (o.ShippingMethodId != string.Empty)
{
Shipping.ShippingRateDisplay r = _app.OrderServices.OrdersFindShippingRateByUniqueKey(o.ShippingMethodUniqueKey, o, _app.CurrentStore);
if (r != null)
{
o.ShippingMethodDisplayName = r.DisplayName;
o.ShippingProviderId = r.ProviderId;
o.ShippingProviderServiceCode = r.ProviderServiceCode;
o.TotalShippingBeforeDiscounts = Math.Round(r.Rate, 2);
//this.AddPackages(r.SuggestedPackages);
}
}
if (o.TotalShippingBeforeDiscountsOverride >= 0)
{
o.TotalShippingBeforeDiscounts = o.TotalShippingBeforeDiscountsOverride;
}
}
示例14: CalculateOrderWithoutRepricing
public bool CalculateOrderWithoutRepricing(Order o)
{
Orders.OrderCalculator calc = new OrderCalculator(this);
calc.SkipRepricing = true;
return calc.Calculate(o);
}
示例15: ApplyVolumeDiscounts
private void ApplyVolumeDiscounts(Order o)
{
// Count up how many of each item in order
List<string> products = new List<string>();
Dictionary<string, int> quantities = new Dictionary<string, int>();
foreach (LineItem item in o.Items)
{
if (!products.Contains(item.ProductId))
{
products.Add(item.ProductId);
}
if (quantities.ContainsKey(item.ProductId))
{
quantities[item.ProductId] += (int)item.Quantity;
}
else
{
quantities.Add(item.ProductId, (int)item.Quantity);
}
}
// Check for discounts on each item
foreach (string id in products)
{
List<MerchantTribe.Commerce.Catalog.ProductVolumeDiscount> volumeDiscounts = _app.CatalogServices.VolumeDiscounts.FindByProductId(id);
int quantity = quantities[id];
MerchantTribe.Commerce.Catalog.ProductVolumeDiscount volumeDiscountToApply = null;
if (volumeDiscounts.Count > 0)
{
// Locate the correct discount in the chart of discounts
foreach (MerchantTribe.Commerce.Catalog.ProductVolumeDiscount volumeDiscount in volumeDiscounts)
{
if (quantity >= volumeDiscount.Qty)
{
volumeDiscountToApply = volumeDiscount;
}
}
//now we have to go through the entire order and discount all items
//that are this id
if (volumeDiscountToApply != null)
{
foreach (LineItem item in o.Items)
{
if (item.ProductId == id)
{
Catalog.Product p = _app.CatalogServices.Products.Find(item.ProductId);
if (p != null)
{
bool alreadyDiscounted = (p.SitePrice > item.AdjustedPricePerItem);
if (!alreadyDiscounted)
{
// item isn't discounted yet so apply the exact price the merchant set
decimal toDiscount = -1 * (item.AdjustedPricePerItem - volumeDiscountToApply.Amount);
toDiscount = toDiscount * item.Quantity;
item.DiscountDetails.Add(new Marketing.DiscountDetail() { Amount = toDiscount, Description = "Volume Discount" });
}
else
{
// item is already discounted (probably by user group) so figure out
// the percentage of volume discount instead
decimal originalPriceChange = p.SitePrice - volumeDiscountToApply.Amount;
decimal percentChange = originalPriceChange / p.SitePrice;
decimal newDiscount = -1 * (percentChange * item.AdjustedPricePerItem);
newDiscount = newDiscount * item.Quantity;
item.DiscountDetails.Add(new Marketing.DiscountDetail() { Amount = newDiscount, Description = percentChange.ToString("p0") + " Volume Discount" });
}
}
}
}
}
}
}
}