NAVcommerce is capable of processing additional order attributes. There are a couple of popular extensions that can be used for this. The most popular one among our customers is the Amasty Order Attributes extension. https://amasty.com/order-attributes-for-magento-2.html
But you can also accomplish this by doing so custom programming. As long as the end result is an additional array of values, named custom_attributes or amasty_order_attributes, on the order object you should be good. Up next the only thing to do is to write a custom order processing code unit which takes care of handling these custom fields and values.
Probably the best way to do is, is to take a copy of the standard code unit 11260665 (NC Sales Order Mgt.), and add your code after the point where the Sales Header has been created. (Around line 125).
There you can safely process the so called Extension Data.
Below is an example of how to do this. In this case we are looking for 3 values; your_reference, preferred_delivery_date and comments and we’re storing them in the same sales header.
In order to make this work we created 5 variables:
Name | Date Type |
---|---|
NCSDKExtensionData | Record NC SDK Extension Data |
AttributeKey | Text |
AttributeValue | Text |
AttributeDataType | Text |
DeliveryDate | Date |
//<-- Amasty order attributes
NCSDKExtensionData.SETRANGE("Record ID",NCSalesHeader.RECORDID);
IF NCSDKExtensionData.FINDSET THEN
REPEAT
NCSDKExtensionData.DeserializeAdditionalOrderValue(AttributeKey,AttributeValue,AttributeDataType);
IF AttributeValue <> '' THEN BEGIN
CASE AttributeKey OF
'your_reference':
SalesHeader."Ext Doc No" := COPYSTR(AttributeValue,1,MAXSTRLEN(SalesHeader."Ext Doc No"));
'preferred_delivery_date':
BEGIN
EVALUATE(DeliveryDate,AttributeValue);
SalesHeader."Requested Delivery Date" := DeliveryDate;
END;
'comments':
SalesHeader."Comment" := COPYSTR(AttributeValue,1,MAXSTRLEN(SalesHeader."Comment" ));
END;
END;
UNTIL NCSDKExtensionData.NEXT = 0;
//Amasty order attributes -->