Table of Contents


Custom Store Provider

Use this feature to customize various aspects of the Storefront module, such as payment processing, adding shipping costs, integration with CRM and more. The system provides StorefrontStandardProvider which implements out-of-the-box features such as reading the store product data from the system's products and collections and does the order processing with supporting merchants such as PayPal Express, Authorize.NET or Stripe.

 

To customize, you need to create an Active Class which is derived from StorefrontStandardProvider and can override certain functionalities as documented below:

public class MyStorefrontProvider: StorefrontStandardProvider
{
    // override the methods that you need.
}

 

The following is the list of methods that you may want to override depending on what your requirements are:

CreateShoppingCart()

Use this method to populate the shopping cart defaults and details. This method returns a ShoppingCartInfo object that contains the current user's information, including their mailing address, shipping address, and more. This method is used when the storefront is loaded and/or whenever it needs to access the shopping card information.
 

CalculateOrder(ShoppingCartInfo info, ShoppingCart cart)

Use this method to add shipping costs, adjust taxes, and apply discount codes or other variables to the shopping cart. All such changes will be applied to the ShoppingCartInfo object passed to the method. 


ProcessOrder(ShoppingCartInfo info, ShoppingCart cart)

Use this method to perform tasks pre- or post-transaction. This method is called when the user clicks on "Checkout". If the payment is processed, the ShoppingCartInfo.OrderNumber will be populated. 

 

Let's say we want to integrate EasyPost or ShipEngine with Magentrix so that you can calculate shipping costs and populate the information.  

public class MyStorefrontProvider: StorefrontStandardProvider
{
    public override ShoppingCartInfo CalculateOrder(ShoppingCartInfo info, ShoppingCart cart)
    {
        var cartInfo = base.CalculateOrder(info, cart);
        
        // Calculate shipping costs (Assumes a class EasyPost has the implementation)
        EasyPost.GetShippingCosts(cartInfo);
        
        return cartInfo;
    }
}


The following code provides guidelines on how to get storefront order information after an order is processed to save the results into an external system such as a CRM.

public class MyStorefrontProvider: StorefrontStandardProvider 
{ 
    public override ShoppingCartInfo ProcessOrder(ShoppingCartInfo info, ShoppingCart cart)
    { 
       var cartInfo = base.ProcessOrder(info, cart);

       // Check to see if the order was processed successfully
       if (!string.IsNullOrEmpty(cartInfo.OrderNumber))
       {
           // Using the ShoppingCartInfo, you may create an "Close/Won" Opportunity
           var oppId = MyCrmOrderHelper.CreateOpportunity(info);

           // Using the cart information, you may create Opportunity line items
           MyCrmOrderHelper.CreateOppLineItems(oppId, cart);
       }
    }
}

 

ShoppingCartInfo

Property NameProperty TypeComments
CCNumberstringCredit card number
CardTypestringCredit card type (Picklist: Visa, Master Card, Amex)
CitystringCity (required)
CommentsstringAdditional comments (multiline text)
CompanystringCompany name
CountrystringCountry (required, default set to “United States”)
DiscountAmountdecimalCalculated discount amount
DiscountCodestringDiscount code
DiscountCodeIdstringIdentifier for the discount code
EmailstringCustomer’s email (required, validated as email)
ErrorMessagestringError message, if applicable
ExpMonthstringCard expiration month (Picklist: “01” to “12”)
ExpYearint?Card expiration year (nullable)
FirstNamestringCustomer’s first name (required)
LastNamestringCustomer’s last name (required)
NameOnCardstringName as it appears on the card
OrderDateDateTime?Order date (nullable)
OrderNumberstringOrder number
PaymentTransactionIdstringPayment transaction ID
PaymentTypestringPayment type (default set to “Credit Card”)
PhonestringCustomer’s phone number (validated as phone)
PostalCodestringPostal code (required)
ShippingdecimalShipping cost (currency)
ShippingCitystringShipping city
ShippingCompanystringShipping company name
ShippingCountrystringShipping country
ShippingFirstNamestringShipping first name
ShippingLastNamestringShipping last name
ShippingPhonestringShipping phone number (validated as phone)
ShippingPostalCodestringShipping postal code
ShippingStatestringShipping state/province two-letter code (auto-uppercase)
ShippingStreetstringShipping street address
StatestringState/Province two-letter code (required, auto-uppercase)
StreetstringStreet address (required)
SubtotaldecimalSubtotal amount (currency)
TaxesdecimalTax rate percentage (numberic value)
TaxesAmountdecimalCalculated tax amount (currency)
TitlestringTitle
TotaldecimalTotal amount (currency)

ShoppingCart

This class has a list of shopping items which are the products that are added to the cart.

Property NameProperty TypeComments
HasPhysicalProductsboolThe cart has physical products that require shipping or not.
ItemsList<ShoppingCartItem>List of items added to the shopping cart.


ShoppingCartItem

Property NameProperty TypeComments
AvailableboolIndicates if the item is available
IdstringIdentifier
NmstringName (of the product)
OptionShoppingProductOptionAssociated product option
OptIdstringOption identifier
PhysicalboolIndicates if the item is physical
ProductShoppingProductAssociated product (ignored by JSON serialization)
QtyintQuantity (required, with a numeric constraint)
TeboolTax exempt flag
TotaldecimalTotal cost (currency)
UpdecimalUnit price (currency)

ShoppingProduct refers to the Storefront Product entity in Magentrix platform.
ShoppingProductOption refers to the Storefront Product Variation which is selected by the user. If the product does not have any variations, this property will be null.