Integration documentation for eCommerce
Ecommerce Object Properties
See the included EcommerceExtensions.cs file for information on how to get and set the following properties.
Cart Detail and Order Detail
Property Name
|
Property Type
|
Property Description
|
tpc_productPurchaseType
|
Int
|
Represents the type of purchase made in Sitefinity. DefaultSitefinity = 0,
Invoice = 1,
Donation = 2,
FormProduct = 3
|
tpc_copiedProps
|
Bool
|
Internal use only
|
tpc_ProductProperties
|
String
|
The properties to save in the product, semicolon delimited list
|
tpc_CrmDetail
|
String
|
The detail entity ID in CRM that represents the Sitefinity detail. Will be Guid.Empty if not created yet
|
tpc_CrmDetailLogicalName
|
String
|
The logical name of the detail entity. salesorderdetail or invoicedetail
|
tpc_ProductName
|
String
|
The name of the product for Invoice products
|
tpc_ProductTotal
|
String
|
The total price of the product for Invoice products.
|
tpc_EntityLogicalName
|
String
|
The logical name of the entity that the invoice product is related to.
|
tpc_Entity
|
String
|
The GUID of the record that the invoice product is paying for
|
tpc_NewState
|
Int
|
The state code to set the record that the invoice product is paying for
|
tpc_NewStatus
|
Int
|
The status code to set on the record that the invoice product is paying for
|
tpc_DonationDescription
|
String
|
The description of the donation product (stored in donation record)
|
tpc_DonationComment
|
String
|
The comment of the donation product (stored in donation record)
|
Cart Order and Order
Property Name
|
Property Type
|
Property Description
|
tpc_Sale
|
String
|
The ID of the record that represents this order.
|
tpc_SaleLogicalName
|
String
|
The logical name of the record that represents this order. salesorder or invoice
|
tpc_SitefinityUser
|
String
|
The ID of the Sitefinity user that placed this order
|
tpc_RecordsToAttach
|
String
|
XML string of a serialized list of EcomAttachedRecord elements that allows you to attach records to the order.
|
tpc_AuxiliaryFieldData
|
String
|
XML string of a serialized list of EcomAuxillaryData that allows you to set additional fields on the order record externally using the TPC API
|
tpc_OrderFailed
|
Bool
|
Whether or not the order failed
|
tpc_OrderFailedStep
|
Int
|
The step that the order failed on. Using the numeric value of the OrderStatus enum.
|
tpc_IsCrmOrder
|
Bool
|
Internal use only
|
Order Payment
Property Name
|
Property Type
|
Property Description
|
tpc_Payment
|
String
|
The ID of the payment record that was created in CRM.
|
EcommerceExtensions.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Reflection;
using System.Web;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using pavliks.PortalConnector.Configuration;
using pavliks.PortalConnector.Crm.Attributes;
using pavliks.PortalConnector.Crm.Connection;
using pavliks.PortalConnector.Extensions;
using pavliks.PortalConnector.Modules;
using pavliks.PortalConnector.Modules.CustomContent;
using pavliks.PortalConnector.UserManagement;
using Telerik.OpenAccess;
using Telerik.Sitefinity;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Data;
using Telerik.Sitefinity.DynamicModules;
using Telerik.Sitefinity.DynamicModules.Model;
using Telerik.Sitefinity.Ecommerce.Orders.Model;
using Telerik.Sitefinity.Licensing;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Modules.Ecommerce.Catalog;
using Telerik.Sitefinity.Modules.Ecommerce.Orders;
using Telerik.Sitefinity.Publishing;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Services;
namespace pavliks.PortalConnector.Crm.Ecommerce
{
internal static class EcommerceHelper
{
internal static T GetProperty<T>(this object obj, string propertyName)
{
var properties = TypeDescriptor.GetProperties(obj);
return properties.GetProperty<T>(propertyName, obj);
}
internal static T GetProperty<T>(this object obj, PropertyDescriptorCollection properties, string propertyName)
{
return properties.GetProperty<T>(propertyName, obj);
}
internal static T GetProperty<T>(this PropertyDescriptorCollection properties, string propertyName, object obj)
{
if (typeof (T) == typeof (Guid) &&
propertyName.EndsWith("Id", StringComparison.InvariantCultureIgnoreCase))
{
string name = propertyName.Left(propertyName.Length - 2);
PropertyDescriptor propertyDescriptor = properties.Find(name, true);
if (propertyDescriptor != null)
{
Guid g;
string s = obj.GetPropertyValue<object>(properties, name) as string;
if (!string.IsNullOrEmpty(s) && Guid.TryParse(s, out g))
{
object o = g;
return (T) o;
}
else
{
return default (T);
}
}
}
return obj.GetPropertyValue<T>(properties, propertyName);
}
internal static void SetProperty<T>(this PropertyDescriptorCollection props, T component, string name, object value) where T : IDynamicFieldsContainer
{
OrdersManager ordersManager = OrdersManager.GetManager();
using (new ElevatedModeRegion(ordersManager))
{
MetafieldPropertyDescriptor propertyDescriptor = props[name] as MetafieldPropertyDescriptor;
if (value is Guid &&
name.EndsWith("Id", StringComparison.InvariantCultureIgnoreCase))
{
var propSansId = props[name.Left(name.Length - 2)] as MetafieldPropertyDescriptor;
if (propSansId != null)
{
value = ((Guid)value).ToString("B");
propertyDescriptor = propSansId;
}
}
if (propertyDescriptor != null)
{
propertyDescriptor.SetValue(component, value);
ordersManager.SaveChanges();
}
}
}
internal static Guid GetCrmProductId(Guid sfProductId)
{
CatalogManager c = CatalogManager.GetManager();
try
{
var product = c.GetProduct(sfProductId);
if (product != null)
{
if (product.OriginalContentId != Guid.Empty)
{
return product.OriginalContentId;
}
return sfProductId;
}
}
catch (Exception)
{
return Guid.Empty;
}
return Guid.Empty;
}
internal static Dictionary<Guid, int> GetSavedProductProperties(OrderDetail detail)
{
Dictionary<Guid, int> productProperties = new Dictionary<Guid, int>();
string productPropertyData = detail.GetProperty<string>("tpc_ProductProperties");
if (!String.IsNullOrEmpty(productPropertyData))
{
productProperties = productPropertyData.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
.Select(p => new KeyValuePair<Guid, int>(Guid.Parse(p.Split(':')[0]), Int32.Parse(p.Split(':')[1])))
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
}
return productProperties;
}
}
}