Add Field to Requst Respons



GetProducts Req :- ExtendedProductProvider : GetProducts,
GetProducts Res :

2
CreateShippingAddress Req : ExtendedAddressProvider >CreateShippingAddress> ExtendedXmlHelper
CreateShippingAddress Res : ,

5
GetBalanceInfo Req : ExtendedCustomerProvider > GetBalanceInfo.
GetBalanceInfo Res : 

7
GetCustomerByContact Req :
GetCustomerByContact Res : ExtendedCustomerXmlParser>ParseCustomer

8
GetCustomers Req :
GetCustomers Res : ExtendedCustomerXmlParser>ParseCustomer

9
Getorder Req :  ExtendedOrderProvider  > CreateOrderListRequest
Getorder Req :


Saveorder Req : ExtendedOrderProvider > CreateSaveOrderRequest,  
Saveorder  Respond :- 

-----
4
GetAnonymousCustomer Req    CustomerProvider > 
GetAnonymousCustomer Res : ExtendedCustomerXmlParser  > ParseCustomer ???

if extra field : 

6
GetColors 

10
GetPriceInfo Req :-
GetPriceInfo Res 

11
GetProducts req  ExtendedProductProvider  > GetProducts
GetProducts res 

12
GetProductSalesAgreementLines

13
CalculateBasket Req: orderprovider >CalculateBasket >  CreateBasketRequest
Response : OrderXmlParser > ParseBasket



Example :
SFS-113783 - 3.4. SAP ENVIRONMENTS & MULTIPLE DIVISIONS
JLAW 110853


CalculateBasket 
3.1. DELIVERY BASED ON ERP FACTORY CALENDARS


Get product from DB and API/ERP



DB
var loadOptions = ObjectFactory.Create<IProductLoadOptions>();
 var product = CommerceFrameworkBase.Products.GetProduct(line.ProductId, options);



API
var product = ShopApi.Catalog.GetProduct(line.ProductId);



DB
protected virtual IList<IProduct> GetProducts(IList<string> productIds)
        {
            var options = CreateLoadOptions();
            return CommerceFrameworkBase.Products.GetProductsByIdList(productIds, options);
        }

        /// <summary>
        /// Creates the load options for getting products' general info.
        /// </summary>
        /// <returns>Load options.</returns>
        protected virtual IProductLoadOptions CreateLoadOptions()
        {
            var loadOptions = ObjectFactory.Create<IProductLoadOptions>();
            loadOptions.LoadRelatedSkus = true;
            loadOptions.VisibleOnly = false;
            loadOptions.CalculateInventory = false;
            loadOptions.CalculatePrices = false;
            loadOptions.CalculateSkuInventory = false;
            loadOptions.CalculateSkuPrices = false;
            loadOptions.LoadImages = false;
            return loadOptions;
        }

Add Theme

STC-106269 - 3.1. INFORMATION MESSAGE ON ORDERING BEYOND AVAILABILITY





Update XML field (Insert,Update,Delete)

select Xml field 
  SELECT id,Fields, Fields.value('(/FieldsDictionary/field[@name="ShowVersionWarning"]/boolean/text())[1]', 'varchar(50)') AS DontDisplayVersionWarningMessage
FROM [dbo].[ShopAccounts]


 update [dbo].[ShopAccounts]
 SET Fields.modify('insert <field name="ShowVersionWarning" type="System.Boolean, mscorlib">
    <boolean>true</boolean>  </field> into (/FieldsDictionary[1])')
 update [dbo].[ShopAccounts]
 SET Fields.modify('insert <field name="VersionWarningStartDate" type="System.DateTime, mscorlib">
    <dateTime>2018-07-02T12:31:18.8564092+05:30</dateTime>
  </field> into (/FieldsDictionary[1])')
 update [dbo].[ShopAccounts]
 SET Fields.modify('insert <field name="DontDisplayVersionWarningMessage" type="System.Boolean, mscorlib">
    <boolean>false</boolean>
  </field> into (/FieldsDictionary[1])')


Delete

UPDATE [dbo].[ShopAccounts] 
SET Fields.modify('delete /FieldsDictionary/field[@name="ShowVersionWarning"][1]')
UPDATE [dbo].[ShopAccounts] 
SET Fields.modify('delete /FieldsDictionary/field[@name="VersionWarningStartDate"][1]')

update exsisting data

UPDATE [dbo].[ShopAccounts] 
SET Fields.modify('replace value of (/FieldsDictionary/field[@name="ShowVersionWarning"]/boolean/text())[1] with "true"')
where email ='accounts@atmosphereair.net.au'
select where 
SELECT id,Fields, Fields.value('(/FieldsDictionary/field[@name="ShowVersionWarning"]/boolean/text())[1]', 'varchar(50)') AS DontDisplayVersionWarningMessage
FROM [dbo].[ShopAccounts]
where Fields.value('(/FieldsDictionary/field[@name="ShowVersionWarning"]/boolean/text())[1]', 'varchar(50)') <>''

Get Product ERP request

Get Product

<?xml version="1.0"?>
<Request>
  <Operation>GetProducts</Operation>
  <Params>
    <VisibleOnly>1</VisibleOnly>
    <LoadRelatedSkus>1</LoadRelatedSkus>
    <LoadVisibilityRules>1</LoadVisibilityRules>
    <CalculatePrices>1</CalculatePrices>
    <CalculateInventory>1</CalculateInventory>
    <CalculateSkuPrices>1</CalculateSkuPrices>
    <CalculateSkuInventory>1</CalculateSkuInventory>
    <CheckStock>1</CheckStock>
    <AccountId></AccountId>
    <AccountType>Customer</AccountType>
    <MultiCurrency>1</MultiCurrency>
    <PageIndex>0</PageIndex>
    <PageSize>5</PageSize>
    <SortField>Id</SortField>
    <SortAscending>1</SortAscending>
    <Filter>
      <for field="Id">
        <Equal>1810000017 </Equal>        
      </for>
    </Filter>
    <ExtraFields>      
    </ExtraFields>
    <WebsiteId>SanaStore</WebsiteId>
  </Params>
</Request>

Get Logged in Customer

#region Get Customer

                    var accountId = CommerceFrameworkBase.Context.AccountId;
                    var accountType = ShopContext.GetCurrent().ShopAccount.Type;

                    ICustomerProfile customer = null;
                    if (accountType == ShopAccountType.Contact)
                        customer = CommerceFrameworkBase.Customers.GetCustomerByContact(accountId);
                    else if (!String.IsNullOrEmpty(accountId) && ((accountType == ShopAccountType.Customer) || (accountType == ShopAccountType.SalesAgent && ShopContext.GetCurrent().IsImpersonating)))
                        customer = CommerceFrameworkBase.Customers.GetCustomer(accountId);
                    #endregion

NEWSLETTER SUBSCRIPTIONS ,SHIPPING COST ,SHIPPING CALCULATION


Mail Settings


SW-103751 - 1.8. CONNECT WITH SPOTLER FOR NEWSLETTER SUBSCRIPTIONS (26)




















SW-103755 - 1.11. SB – SHIPPING COST IN SHOPPING CART SUMMARY (22), THE MOUSE-OVER CART (24), AND THE CHECKOUT RIGHT COLUMN SUMMARY (23)'














STC-106270 - 3.2. SHIPPING CALCULATION METHOD BY WEIGHT AND ORDER TOTAL



Ticket 106367: Freight charges query (Federal merchent project)

to add item to drop down update UOMDependantProvider : FixedProviderBase


Page.shipping-method.js







AVON project also did similre customization





Shipping Cost and Checkout Smartware


SHOW PRODUCTS IN SUMMARY COLUMN 

SW-103756 - 1.12. CHECKOUT – SHOW PRODUCTS IN SUMMARY COLUMN (23)

_CheckoutCartSummary.cshtml 





SHIPPING COST IN SHOPPING CART SUMMARY

SW-103755 - 1.11. SB – SHIPPING COST IN SHOPPING CART SUMMARY (22), THE MOUSE-OVER CART (24), AND THE CHECKOUT RIGHT COLUMN SUMMARY (23)


ExtendedShippingCostStep > 

public override void Execute(BasketCalculationContext context)
        {
            if (context.SourceBasket.BasketLines.Count == 0)
                return;
 
            if (!CommerceFrameworkBase.ShippingMethods.AreShippingCostsEnabled())
            {
                if (context.SourceBasket.BasketLines.RemoveServiceLine(SalesLineTypes.ShippingCosts) || context.SourceBasket.ShippingMethodId.HasValue)
                {
                    context.SourceBasket.ShippingMethodId = null;
                    OnSourceBasketChanged(context);
                }
                return;
            }
 
            context.SourceBasket.TotalGrossWeight = CommerceFrameworkBase.Orders.CalculateTotalWeight(context.SourceBasket);
            context.SourceBasket.TotalPriceExcludingDiscount = CalculateTotalPriceExcludingDiscount(context.SourceBasket);
 
            var shipTo = CommerceFrameworkBase.Addresses.GetShippingAddress(context.SourceBasket, context.Settings.IsSalesAgentImpersonatingContact);
 
            // If User is not logged in to system, get selected country's shippinng cost
 
            #region Get login Customer
            var accountId = CommerceFrameworkBase.Context.AccountId;
            var accountType = ShopContext.GetCurrent()?.ShopAccount?.Type;
            ICustomerProfile customer = null;
 
            if (accountType != null)
            {
                if (accountType == ShopAccountType.Contact)
                    customer = CommerceFrameworkBase.Customers.GetCustomerByContact(accountId);
                else if (!String.IsNullOrEmpty(accountId) && ((accountType == ShopAccountType.Customer) || (accountType == ShopAccountType.SalesAgent && ShopContext.GetCurrent().IsImpersonating)))
                    customer = CommerceFrameworkBase.Customers.GetCustomer(accountId);
            }
            else
                customer = CommerceFrameworkBase.Customers.GetCustomer(accountId);
            #endregion
 
            //Get selected countryID and set 'shipTo' Address, for get the selected country's shippinng cost.
            if (accountType == null)
            {
                var countryIdFromCookies = CookiesState.GetValue("B2CCountryId");
 
                if (!countryIdFromCookies.IsEmptyString())
                {
                    shipTo = new CustomerAddress();
                    shipTo.CountryId = countryIdFromCookies;
                }
            }
 
            //Set Ship Address property
            context.SourceBasket.ShippingAddress = shipTo;
 
            var line = context.SourceBasket.BasketLines.FindServiceLine(SalesLineTypes.ShippingCosts);
            IShippingMethod shippingRate = null;
            bool isDefaultRate = false;
 
 
            //1. Get "Deault Shipping method" and set value to the "ShippingMethodId" 
 
            // Check if default shipping already set            
            if (!((Basket)context.SourceBasket).IsDefaultShipMethodChecked)
            {
                ExtendedShippingMethodManager extendedShippingMethodManager = new ExtendedShippingMethodManager();
                var shippingMethods = extendedShippingMethodManager.GetAllShippingMethods();
 
                if (shippingMethods.ToList().Count > 0)
                {
                    //Get Default Shopping method  and set values                                        
                    var defaultshipMethod = shippingMethods.Where(i => ((ShippingMethod)i).IsDefaultShippingMethod == true).FirstOrDefault();
 
                    if (defaultshipMethod != null)
                    {
                        context.SourceBasket.ShippingMethodId = defaultshipMethod.Id;
                        ((Basket)context.SourceBasket).IsDefaultShipMethodChecked = true;
                        ShopApi.Basket.ModifyCurrentBasket(basket =>
                        {
                            ((Basket)basket).IsDefaultShipMethodChecked = true;
                            return true;
                        });
                    }
                }
            }
 
            // If the customer is EX worker,Then Reset deails to EX work shipping details. 
            var customerShippingMethodCode = ((CustomerProfile)customer).ShippingMethodCode;
 
            if (customerShippingMethodCode == "EXW")
            {
                //Get the EXW Shipping Details and fill sourceLine , calculatedLine               
                var shippingMethods = new ExtendedShippingMethodManager().GetAllShippingMethods();
 
                if (shippingMethods.ToList().Count > 0)
                {
                    //Get EX Work enable shipping Cost                                       
                    var exWorkMethod = shippingMethods.Where(i => ((ShippingMethod)i).IsExWorx == true).FirstOrDefault();
 
                    if (exWorkMethod != null)
                        context.SourceBasket.ShippingMethodId = exWorkMethod.Id;
                }
            }
 
            if (context.SourceBasket.ShippingMethodId.HasValue)
            {
                shippingRate = CommerceFrameworkBase.ShippingMethods.CalculateShippingRate(context.SourceBasket.ShippingMethodId.Value, context.SourceBasket, shipTo);
                if (shippingRate == null)
                    HandleUnavailableShippingMethod(context.SourceBasket, context.SourceBasket.ShippingMethodId.Value, shipTo);
            }
            else
            {
                var shippingRates = CommerceFrameworkBase.ShippingMethods.CalculateShippingRates(context.SourceBasket, shipTo);
                shippingRate = GetDefaultShippingRate(shippingRates);
                isDefaultRate = true;
            }
 
            if (shippingRate == null)
            {
                if (line != null || context.SourceBasket.ShippingMethodId.HasValue)
                {
                    if (line != null)
                        context.SourceBasket.BasketLines.Remove(line);
                    context.SourceBasket.ShippingMethodId = null;
                    context.SourceBasket.IsSuggestedShippingMethod = true;
                    OnSourceBasketChanged(context);
                }
                return;
            }
 
            decimal shippingCost = shippingRate.Cost.HasValue ? shippingRate.Cost.Value : 0;
 
            if (context.SourceBasket.BasketLines.SetServiceLine(shippingRate.Id, shippingRate.Name, shippingCost, SalesLineTypes.ShippingCosts))
            {
                if (shippingRate.Id != Guid.Empty)
                    context.SourceBasket.ShippingMethodId = shippingRate.Id;
                else
                    context.SourceBasket.ShippingMethodId = null;
 
                context.SourceBasket.IsSuggestedShippingMethod = isDefaultRate;
                OnSourceBasketChanged(context);
            }
        }





Guidance for the issues . 

CUSTOMERS ALSO BOUGHT SECTION ON PDP

_componentb2b
JLAW-110855 - 3.18. CUSTOMERS ALSO BOUGHT SECTION ON PDP (JLAW-58229)




BOM Items / SPAREPARTS on Product details page

ACTEN-105654 - 3.5. HAVING DIFFERENT SPAREPARTS FOR DIFFERENT ITEM VERSIONS
REB-B-113059 - 3.2. PRODUCT DETAIL PAGE – BILL OF MATERIALS TAB





REB-B-113059 - 3.2. PRODUCT DETAIL PAGE – BILL OF MATERIALS TAB




Show Logo in Product Images

SW-103747 - 1.4. BRAND LOGO’S ON PDP (20)






Popup warning

issue: ACTEN-108915 - Popup warning




popup looks like this





1. Step
To add admin setting on shop account section , need to update ShopAccount.cs
 Sana.Commerce.Sdk\DomainModel\Shop\ShopAccount.cs




2. Step
by creating these field need to create 2 fields in DB >



3.Step

Create ExtendedShopAccountModel to map ShopAccount DB  Fields
we hide the versionMessageDate Field by display  = false 




4.Step
Register ExtendedShopAccountModel in Addon.cs

5.Step
Add admin setting text to Admin. resx


6.Step
by default Show Version Warning need to be ENABLE. so need to override  CreateGet() 
and register it adminarearegistration.cs






Now admin settings are completed.


7.Step
Create a new popup for this issue.




8. now when user go to the Product detail page of a product then  click add to cart button


when admin settings are  getting the cashing need to update






when click add to cart button popup need to be open

for that, we create an ajax call.




var showAddtoCartVersionPopup = function (type) {

            var data = getLines(type);
            if (data.length > 0) {
                return $.ajax({
                    url: Sana.Urls.Home() + 'Basket/IsShowVirsionPopup',
                    type: 'GET',
                    data: { IsPopupShow: "true" },
                    dataType: 'json',
                    success: function (data) {
                        if (data === "True") {
                            var popup = $('#SparePartVirstionPopup');
                            Sana.Popup.open('#SparePartVirstionPopup');
                            return;
                        }
                        else if (data === "False") {
                            addToBasket(type);
                        }                     
                    },
                    error: function (request, error) {
                        return;                     
                    }
                });
            }
        };



Then RegisterSystemRoutes on ExtendedBasketController




on Web.config we keep virsion woning date .

var VersionWarningDays = ConfigurationManager.AppSettings["VersionWarningDays"];