Example #1
0
        public Shipping()
        {
            this._Shippingitems = new Iesi.Collections.Generic.HashedSet <Shippingitem>();

            ShippingFactory theFactory = new ShippingFactory();

            _repository = theFactory.createRepository();
            if (_repository == null)
            {
                throw new NotImplementedException();
            }
        }
    private void BuildShoppingCart(string requestXml, NewOrderNotification notification)
    {
        foreach (Item item in notification.shoppingcart.items)
        {
            XmlNode[] node = item.merchantprivateitemdata.Any;

            Product product = DataAccessContext.ProductRepository.GetOne(
                StoreContext.Culture,
                item.merchantitemid,
                new StoreRetriever().GetCurrentStoreID()
                );

            if (node.Length <= 1)
            {
                StoreContext.ShoppingCart.AddItem(
                    product, item.quantity);
            }
            else
            {
                // Creating option item from google checkout is not details of option type is text.
                OptionItemValueCollection optionCollection = OptionItemValueCollection.Null;
                if (!String.IsNullOrEmpty(node[1].InnerText))
                {
                    optionCollection = new OptionItemValueCollection(
                        StoreContext.Culture, node[1].InnerText, item.merchantitemid);
                }

                StoreContext.ShoppingCart.AddItem(
                    product, item.quantity, optionCollection);
            }
        }

        Log.Debug("SetShippingDetails");
        Vevo.Base.Domain.Address address = new Vevo.Base.Domain.Address(
            notification.buyershippingaddress.contactname,
            "",
            notification.buyerbillingaddress.companyname,
            notification.buyershippingaddress.address1,
            notification.buyershippingaddress.address2,
            notification.buyershippingaddress.city,
            notification.buyershippingaddress.region,
            notification.buyershippingaddress.postalcode,
            notification.buyershippingaddress.countrycode,
            notification.buyerbillingaddress.phone,
            notification.buyerbillingaddress.fax);

        StoreContext.CheckoutDetails.ShippingAddress = new ShippingAddress(address, false);

        Log.Debug("Set Shipping ");
        MerchantCalculatedShippingAdjustment shippingAdjust = (MerchantCalculatedShippingAdjustment)notification.orderadjustment.shipping.Item;

        string         shippingID = DataAccessContext.ShippingOptionRepository.GetIDFromName(shippingAdjust.shippingname);
        ShippingMethod shipping   = ShippingFactory.CreateShipping(shippingID);

        shipping.Name = shippingAdjust.shippingname;
        StoreContext.CheckoutDetails.SetShipping(shipping);
        StoreContext.CheckoutDetails.SetCustomerComments("");

        PaymentOption paymentOption = DataAccessContext.PaymentOptionRepository.GetOne(
            StoreContext.Culture, PaymentOption.GoogleCheckout);

        StoreContext.CheckoutDetails.SetPaymentMethod(
            paymentOption.CreatePaymentMethod());

        Log.Debug("Set Coupon ID");
        StoreContext.CheckoutDetails.SetCouponID(GetCouponCode(notification.orderadjustment.merchantcodes.Items));

        Log.Debug("Set Gift");
        string giftID = GetGiftCertificateCode(notification.orderadjustment.merchantcodes.Items);

        if (giftID != String.Empty)
        {
            StoreContext.CheckoutDetails.SetGiftCertificate(giftID);
        }

        StoreContext.CheckoutDetails.SetGiftRegistryID("0");
        StoreContext.CheckoutDetails.SetShowShippingAddress(true);
    }