Developer forum

Forum » Integration » NAV 2015 product units and packaging

NAV 2015 product units and packaging

Andrejs Zavorotnijs
Reply
Hi 
 
We have client which use NAV 2015 and have customizations, regarding packaging's and product units of measure
we made 2 custom request responses in NAV:
  • first is product package information data, which we need in frontend to customer can choose packaging => imported in DW to product custom fields (MultiSelectList and DropdownList)
 
  •  
  • second they have custom table in NAV with product available units and multiplier(Factor) => imported in DW to EcomProductUnitOfMeasure
  •  
 
in DW that looks like this
 
 
1) If that works by default with Live Integration?
For every packaging, we made product(item) in NAV with package name and package price, so we want to use packaging service, like simple products orderline
price is calculated depend on product weight and quantity => product package price = product weight * product quantity * product package price
 
2)How we can do this?
product price = product price * product quantity * unit Factor
 
How we can handle all this in Live integration and in NAV 2015, I mean product live prices depend on unit, correct cart calculation and posting orders with correct prices
 
 
 

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

I think you can easily do that with a price provider:

This is just an example with some random checks for quantity, user customer number and how to find a custom product field.

So in this one, you can locate the factor and add that to the price - part of the example. 

The priceprovider should not handle quantity - that will be handled by the cart - so this one needs to return the correct unitprice - but unit price can vary by the qty in cart, hence the example of that.

namespace Dynamicweb.Ecommerce.Examples.Prices
{
    public class PriceProviderSample : PriceProvider
{
        public override PriceRaw FindPrice(PriceContext context, PriceProductSelection selection)
        {
// Get the price from the DefaultPriceProvider
DefaultPriceProvider defaultProvider = new DefaultPriceProvider();
PriceRaw customPrice = defaultProvider.FindPrice(context, selection);
 
var someVariable = selection.Product.ProductFieldValues["someCustomField"].Value;
//find your own price
if (context.Customer != null && context.Customer.CustomerNumber.StartsWith("abc"))
{
customPrice.Price *= .90;
return customPrice;
}
else if (selection.Quantity > 1)
{
customPrice.Price *= .95;
return customPrice;
}
 
return customPrice;
}
 
    }
}
 
Andrejs Zavorotnijs
Reply

Hi Nicolai

Thx for answer

Yep I know about changing prices in DW, but that work only in product list and product details page

As I remember it doesn't work in Cart if cart communication "Full" and if posting order =>  in NAV there will base unit price

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Price providers also works in the cart.

But if you use full cart communication, then NAV is in charge 100% and you have to do the change in NAV.

 
Andrejs Zavorotnijs
Reply

Yep 

Is that possible to do all changes in NAV only, or some part should be done in DW?

I'm not familiar with NAV, in BC there are subscribers to DW plugin, but where in NAV should be done changes for live prices with units, cart and post order

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Anrejs,
the NAV language syntax is the same as for BC. So there is a procedure called PutEcomOrdersLive that you can look into.
There is a code that is doing some calculations based on the unit id passed from the Dynamicweb request:
              uom := GetUOMCode(Get_TextFromNode(XMLNode,'column[@columnName=''OrderLineUnitId'']'));
              IF uom <> '' THEN BEGIN
                itemUOM.GET(item."No.", uom);
                salesline."Unit of Measure" := uom;
                salesline."Unit of Measure Code" := uom;
                QtyPerUOM := itemUOM."Qty. per Unit of Measure";
              END ELSE BEGIN
                uom := item."Base Unit of Measure";
                QtyPerUOM := 1;
              END;

So maybe it will be relevant to investigate.
Also you can use the NAV development environment debugger and connect it by calling the request from the Test tool.
BR, Dmitrij

 
Andrejs Zavorotnijs
Reply

Hi Dmitriy

Thx for answer

As I understand PutEcomOrdersLive procedure for creating order in NAV

Can you suggest, what is the best practice to get live prices for product units:

  • price provider
  • Changes in NAV, to get correct unit prices

 

You must be logged in to post in the forum