public static void DoOrderAdjustments(OrderAdjustment orderAdj, Basket basket)
        {
            TraceContext trace    = WebTrace.GetTraceContext();
            string       traceKey = "OrderAdjustmentHelper.DoOrderAdjustments";

            if (orderAdj == null)
            {
                throw new ArgumentNullException("orderAdj", "OrderAdjustment can't be null");
            }

            OrderAdjustmentMerchantcodes oamcs = orderAdj.merchantcodes;

            if (oamcs != null && oamcs.Items != null)
            {
                trace.Write(traceKey, "check merchant codes");
                Object[]                  merchantCodes = oamcs.Items;
                CouponAdjustment          coupAdj;
                GiftCertificateAdjustment giftCertAdj;

                //coupon and giftcertificate adjustment
                foreach (Object obj in merchantCodes)
                {
                    if (obj == null)
                    {
                        continue;
                    }
                    if (obj is CouponAdjustment)
                    {
                        coupAdj = (CouponAdjustment)obj;
                        trace.Write(traceKey, "Apply coupon: " + coupAdj.code + ", " + coupAdj.appliedamount);
                        OrderAdjustmentHelper.AdjustCoupon(basket, coupAdj);
                    }
                    else if (obj is GiftCertificateAdjustment)
                    {
                        giftCertAdj = (GiftCertificateAdjustment)obj;
                        trace.Write(traceKey, "Apply gift cert: " + giftCertAdj.code + " for " + giftCertAdj.appliedamount.Value);
                        OrderAdjustmentHelper.AdjustGiftCertificate(basket, giftCertAdj);
                    }
                }
            }

            OrderAdjustmentShipping oas = orderAdj.shipping;

            if (oas != null && oas.Item != null)
            {
                trace.Write(traceKey, "check shipping adjustments");
                Object shipAdj = oas.Item;
                if (shipAdj is MerchantCalculatedShippingAdjustment)
                {
                    MerchantCalculatedShippingAdjustment mcsa = (MerchantCalculatedShippingAdjustment)shipAdj;
                    OrderAdjustmentHelper.AdjustMerchantCalculatedShipping(basket, mcsa);
                }
                else if (shipAdj is FlatRateShippingAdjustment)
                {
                    FlatRateShippingAdjustment frsa = (FlatRateShippingAdjustment)shipAdj;
                    OrderAdjustmentHelper.AdjustFlatRateShipping(basket, frsa);
                }
                else if (shipAdj is PickupShippingAdjustment)
                {
                    PickupShippingAdjustment pusa = (PickupShippingAdjustment)shipAdj;
                    OrderAdjustmentHelper.AdjustPickupShipping(basket, pusa);
                }
            }

            //tax adjustments
            if (orderAdj.totaltax != null && orderAdj.totaltax.Value > 0)
            {
                trace.Write(traceKey, "process tax adjustments");
                OrderAdjustmentHelper.AdjustTax(basket, orderAdj.totaltax.Value);
            }
        }