Skip to main content
Question

Catalog screen Update non stock item Pallets field total selected quantity when click on Add To Cart both stock and non stock item insert to Cart.


Forum|alt.badge.img+1

Hi Everyone,

    In Catalog screen I added non stock item PALLET as shown in screen shot. I want when I insert pallets quantity on stock item that all item quantity total update on non stock item pallets field.as shown screen shot.

 


When click Add To Cart that non stock item also inserted on Cart.
I write below code but non stock item not inserting on Cart.
protected void InventoryLines_RowUpdated(PXCache c, PXRowUpdatedEventArgs e, PXRowUpdated del)
  {
            InventoryLines inventoryLines = e.Row as InventoryLines;
          UpdateNonStockItemPallets();
}
 

private void UpdateNonStockItemPallets()
        {
            PXResultset<InventoryLines> pxresultset = base.Base.FilteredItems.Select(Array.Empty<object>());
            foreach (PXResult<InventoryLines> pxresult in pxresultset)
            {
                InventoryLines row = pxresult;
                // Fetch the non-stock item record
                InventoryItem nonStockItem = PXSelect<InventoryItem,
                                          Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>,
                                                And<InventoryItem.itemType, Equal<INItemTypes.nonStockItem>>>>
                                          .Select(Base, row.InventoryID);

                if (nonStockItem != null)
                {
                    // Calculate the total quantity of items in the cart and selected for order
                    int selectedOrderQty = CalculateSelectedOrderQty();
                  
                    int totalQty = selectedOrderQty;

                    // Update the UsrPallets field for the non-stock item
                    row.GetExtension<InventoryLinesExt>().UsrPallets = totalQty;


                    row.Qty = totalQty;
                    row.Selected = totalQty > 0;
}
}
}

protected int CalculateSelectedOrderQty()
        {
            PXResultset<InventoryLines> pxresultset = base.Base.FilteredItems.Select(Array.Empty<object>());
            decimal num = 0m;
            foreach (PXResult<InventoryLines> pxresult in pxresultset)
            {
                InventoryLines inventoryLines = pxresult;
                num += Convert.ToDecimal(PXCacheEx.GetExtension<InventoryLinesExt>(inventoryLines).UsrPallets);
            }
            return Convert.ToInt32(num);
        }

Thanks

0 replies

Be the first to reply!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings