Skip to content

Instantly share code, notes, and snippets.

View ArveSystad's full-sized avatar
🤓

Arve Systad ArveSystad

🤓
View GitHub Profile
@model InlineArticleProduct
<article>
<h1>@Model.Name</h1>
<p class="price">@Model.Price</p>
</article>
public class ViewTemplateCoordinator : IViewTemplateModelRegistrator
{
public void Register(TemplateModelCollection viewTemplateModelRegistrator)
{
viewTemplateModelRegistrator.Add(
typeof(ProductVariant),
new TemplateModel
{
Name = "InlineArticleProducts",
AvailableWithoutTag = false,
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)
foreach (Shipment shipment in form.Shipments)
{
List<LineItem> items = GetSplitShipmentLineItems(shipment);
// Calculate sales and shipping taxes per items
foreach (LineItem item in items)
[...]
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 (OrderForm form in order.OrderForms)
{
decimal totalTaxes = 0;
foreach (Shipment shipment in form.Shipments)
{
foreach (LineItem item in shipment.Parent.LineItems)
{
[...]
public Cart GetShoppingCart(int orderGroupId)
{
var parameters = new OrderSearchParameters
{
SqlWhereClause = "OrderGroupId = " + orderGroupId
};
var options = new OrderSearchOptions
{
Classes = new StringCollection { "ShoppingCart" },
RecordsToRetrieve = 1
[EditorDescriptorRegistration(TargetType = typeof(XhtmlString), UIHint = "MyUIHint")]
public class MyEditorDescriptor : XhtmlStringEditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
{
base.ModifyMetadata(metadata, attributes);
KeyValuePair<string, object> tinyMceSettings = metadata.EditorConfiguration.FirstOrDefault(x => x.Key == "settings");
var dictionary = tinyMceSettings.Value as Dictionary<string,object>;
if (dictionary != null)
[Display]
[UIHint("MyUIHint")]
public virtual XhtmlString SexyTextArea { get; set; }
[ContentType(GUID = "6CA27C21-FF6C-425F-A87D-1C7E4BE26AA8", AvailableInEditMode = true)]
public class Review : ContentData, IContent
{
public virtual int Rating { get; set; }
public virtual string ProductNumber { get; set; }
[BackingType(typeof(PropertyLongString))]
public virtual string Text { get; set; }
public virtual string UserDisplayName { get; set; }
//IContent implementation