Skip to content

Instantly share code, notes, and snippets.

View ArveSystad's full-sized avatar
🤓

Arve Systad ArveSystad

🤓
View GitHub Profile
public Cart GetShoppingCart(int orderGroupId)
{
var parameters = new OrderSearchParameters
{
SqlWhereClause = "OrderGroupId = " + orderGroupId
};
var options = new OrderSearchOptions
{
Classes = new StringCollection { "ShoppingCart" },
RecordsToRetrieve = 1
foreach (OrderForm form in order.OrderForms)
{
decimal totalTaxes = 0;
foreach (Shipment shipment in form.Shipments)
{
foreach (LineItem item in shipment.Parent.LineItems)
{
[...]
private List<LineItem> GetSplitShipmentLineItems(Shipment shipment)
{
List<LineItem> items = Shipment.GetShipmentLineItems(shipment);
return items.Select(x => new LineItem
{
CatalogEntryId = x.CatalogEntryId,
ExtendedPrice = x.ExtendedPrice / x.Quantity * Shipment.GetLineItemQuantity(shipment, x.LineItemId), // Need the extended price for this shipment
Quantity = Shipment.GetLineItemQuantity(shipment, x.LineItemId),
}).ToList();
}
foreach (Shipment shipment in form.Shipments)
{
List<LineItem> items = GetSplitShipmentLineItems(shipment);
// Calculate sales and shipping taxes per items
foreach (LineItem item in items)
[...]
foreach (LineItem item in items)
{
OrderAddress address = GetAddressByName(form, shipment.ShippingAddressId);
if (address != null) // no taxes if there is no address
{
CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(item.CatalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
if (entryDto.CatalogEntry.Count > 0) // no entry, no tax category, no tax
{
CatalogEntryDto.VariationRow[] variationRows = entryDto.CatalogEntry[0].GetVariationRows();
if (variationRows.Length > 0)
public class ViewTemplateCoordinator : IViewTemplateModelRegistrator
{
public void Register(TemplateModelCollection viewTemplateModelRegistrator)
{
viewTemplateModelRegistrator.Add(
typeof(ProductVariant),
new TemplateModel
{
Name = "InlineArticleProducts",
AvailableWithoutTag = false,
@model InlineArticleProduct
<article>
<h1>@Model.Name</h1>
<p class="price">@Model.Price</p>
</article>
public class InlineArticleProductController : ActionControllerBase
{
public ActionResult Index(ProductVariant currentContent)
{
var model = new InlineArticleProduct
{
Name = "A hat",
Price = 250
};
public class InlineArticleProduct
{
public string Name { get; set; }
public decimal Price { get; set; }
}
[ContentType(GUID = "34D69D83-83DF-4739-9132-8805BBC82196")]
[MediaDescriptor(ExtensionString = "pdf")]
public class PdfFile : MediaData
{
}