Developer forum

Forum » Integration » Specified discount on product in live integration BC

Specified discount on product in live integration BC

Martin Moen
Reply

We are integrating with BC, and on the product page we do get the correct discounted price, and in the cart we do get the discounted price including the specified discount.

But we would like to show the specified discount in both amount and percentage on the product page, and in the product lists.
Is this supported, or do we have to extend the integration in order to make it work?


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Martin,
unfortunately that is not implemented by default. So you need to implement it on your own. You can try to implement the own BC extension so it can return the default unit price 
and the discounts percents and then in the live integration store it in the product info object and then access and render it in the product template extender.
BR, Dmitrij

 
Martin Moen
Reply

Thanks Dmitrij, I feared that was the answer. We will look into it.

Do we have to create our own new version of the live integration dll, or can we extend it through a separate dll?
Would like to keep the standard dll's as clean as possible to avoid a mess when updating.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Martin,
yes, you can keep the DynamicwebLiveIntegration dll and use the extensibility points from  it.
You can create the Custom Product fields in Dynamicweb and then Enable the sending Custom Product fields in the request in the Live integration setttings,
so once the custom fields are populated in the BC and are present in the reponse then they automatically will be stored back in the Live integration
productInfo[productField.SystemName] object, so you can then access it in the newly created Ecommerce.Products.ProductTemplateExtender by the coed like this:

using Dynamicweb.Ecommerce.Integration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products;
using Dynamicweb.Ecommerce.Prices;
using Dynamicweb.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplateExtenders
{
    /// <summary>
    /// 
    /// </summary>
    public class ProductTemplateExtender : Ecommerce.Products.ProductTemplateExtender
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="template"></param>
        public override void ExtendTemplate(Template template)
        {
            if (template.TagExists("YourTagName"))
            {
                if (Global.IsIntegrationActive)
                {
                    var productInfo = ProductManager.GetProductInfo(Product);
                    if(productInfo != null) {
                        string customFieldValue = productInfo["ProductFieldSystemName"].ToString();
                        template.SetTag("YourTagName", customFieldValue);                        
                    }
                }
            }
        }

In the BC exension you can subscribe to those events in order to add your custom fields values:
ProductsPublisher.OnAddItemCustomerOnBeforeAddItemUOM(item, pXmlNode, node); //This is available only in the last released 1.2.0.20 version
OR
ProductsPublisher.OnAddProductInfoXmlNode(pXmlNode, item, customer);
then in one of those subscribers you will need to modify the 
pXmlNode
so fill the custom fields xml tags with the appropriate BC values using the AL XML functions.

BR, Dmitrij

 

You must be logged in to post in the forum