Beispiel #1
0
        private static BasketItem GetTaxParentItemForShipping(BasketItem item)
        {
            // IF THIS IS NOT A CHILD ITEM, USE SELF AS TAX PARENT
            if (!item.IsChildItem)
            {
                return(item);
            }

            // CHECK FOR A VALID PARENT
            BasketItem parentItem = item.GetParentItem(false);

            if (parentItem != null)
            {
                // IF THIS IS NOT A PRODUCT, DEFER TO THE IMMEDIATE PARENT ITEM AS TAX PARENT
                if (item.OrderItemType != OrderItemType.Product)
                {
                    return(GetTaxParentItemForShipping(parentItem));
                }

                // DETERMINE IF THIS ITEM IS A CHILD PRODUCT IN A KIT
                BasketItem kitMasterItem = item.GetParentItem(true);
                if (kitMasterItem != null)
                {
                    Product kitMasterProduct = kitMasterItem.Product;
                    if (kitMasterProduct != null && kitMasterProduct.KitStatus == KitStatus.Master)
                    {
                        // ITEM IS A CHILD PRODUCT IN A KIT, IF THE KIT IS BUNDLED USE MASTER ITEM AS TAX PARENT
                        if (!kitMasterProduct.Kit.ItemizeDisplay)
                        {
                            return(kitMasterItem);
                        }
                    }
                }
            }

            // ITEM IS NOT PART OF A KIT, OR IS IN AN ITEMIZED KIT, USE SELF AS TAX PARENT
            return(item);
        }
        private ShippableItem GetShippableItem(BasketItem basketItem, List <int> kitMasterItems)
        {
            // MAKE SURE THIS IS A SHIPPABLE PRODUCT
            if (basketItem.OrderItemType == OrderItemType.Product && basketItem.Shippable != Shippable.No)
            {
                if (!basketItem.IsChildItem)
                {
                    // NOT A CHILD ITEM
                    Product product = basketItem.Product;
                    if (product.KitStatus == KitStatus.Master)
                    {
                        // THIS IS A KIT MASTER PRODUCT, NO NEED TO CONTINUE IF WE ALREADY CREATED A SHIPPABLE ITEM
                        if (kitMasterItems.Contains(basketItem.Id))
                        {
                            return(null);
                        }
                        // RECORD THAT WE ARE ADDING A KIT MASTER PRODUCT
                        kitMasterItems.Add(basketItem.Id);
                    }

                    // CREATE THE SHIPPABLE ITEM INSTANCE
                    return(new ShippableItem(basketItem));
                }

                // SPECIAL HANDLING FOR CHILD PRODUCTS (FROM KITS)
                BasketItem parentItem    = basketItem.GetParentItem(true);
                Product    parentProduct = parentItem.Product;

                // ENSURE THE PARENT PRODUCT IS A KIT
                if (parentProduct != null && parentProduct.KitStatus == KitStatus.Master)
                {
                    // WE ONLY WANT A SINGLE SHIPPABLE ITEM FOR THE ROOT PRODUCT
                    if (kitMasterItems.Contains(parentItem.Id))
                    {
                        return(null);
                    }
                    kitMasterItems.Add(parentItem.Id);
                    return(new ShippableItem(parentItem));
                }
            }
            return(null);
        }
Beispiel #3
0
        private static bool DisplayBasketItem(BasketItem item, bool includeShipping)
        {
            // DO NOT INCLUDE ITEMS THAT ARE NOT OF A DISPLAYABLE TYPES
            if (includeShipping)
            {
                if (Array.IndexOf(_displayItemTypesWithShipping, item.OrderItemType) < 0)
                {
                    return(false);
                }
            }
            else
            {
                if (Array.IndexOf(_displayItemTypes, item.OrderItemType) < 0)
                {
                    return(false);
                }
            }

            // ALWAYS SHOW ROOT ITEMS AND NON PRODUCT ITEMS
            if (!item.IsChildItem || item.OrderItemType != OrderItemType.Product)
            {
                return(true);
            }

            // ONLY PRODUCT CHILD ITEMS REACH HERE
            BasketItem parentItem = item.GetParentItem(true);

            // IF THE PARENT ITEM IS ITEMIZED, CHILD PRODUCTS ARE VISIBLE
            if (parentItem != null && parentItem.Product != null && parentItem.Product.Kit != null && parentItem.Product.Kit.ItemizeDisplay)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        private static bool DisplayItemForShipment(BasketItem item, int shipmentId)
        {
            // DO NOT INCLUDE ITEMS THAT ARE NOT IN THIS SHIPMENT, GIFT CERTIFICATE PAYMENTS, OR TAXES
            if (item.ShipmentId != shipmentId ||
                item.OrderItemType == OrderItemType.GiftCertificatePayment ||
                item.OrderItemType == OrderItemType.Tax)
            {
                return(false);
            }

            // ALWAYS SHOW ROOT ITEMS AND DISCOUNTS
            if (!item.IsChildItem || item.OrderItemType == OrderItemType.Discount)
            {
                return(true);
            }

            // ONLY NON DISCOUNT CHILD ITEMS REACH HERE.  DO NOT SHOW NON-PRODUCT CHILD ITEMS
            if (item.OrderItemType != OrderItemType.Product)
            {
                return(false);
            }

            // ONLY PRODUCT CHILD ITEMS REACH HERE
            BasketItem parentItem = item.GetParentItem(true);

            // IF THE PARENT ITEM IS ITEMIZED, CHILD PRODUCTS ARE VISIBLE
            if (parentItem != null && parentItem.Product != null && parentItem.Product.Kit != null && parentItem.Product.Kit.ItemizeDisplay)
            {
                return(true);
            }

            // THE PARENT IS NOT ITEMIZED.  IN THIS CASE, WE SHOULD STILL SHOW THE PRODUCT IF THE
            // PARENT IS IN A DIFFERENT SHIPMENT (OR POSSIBLY NON-SHIPPING) THIS AVOIDS THE
            // POSSIBILITY THAT A SHIPMENT WILL APPEAR TO NOT CONTAIN ANY PRODUCTS
            return(parentItem.ShipmentId != shipmentId);
        }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     if (_BasketItem != null)
     {
         Product product = _BasketItem.Product;
         if (product != null)
         {
             //OUTPUT THE PRODUCT NAME
             string productName = _BasketItem.Name;
             if (_BasketItem.ProductVariant != null)
             {
                 string variantName = string.Format(" ({0})", _BasketItem.ProductVariant.VariantName);
                 if (!productName.EndsWith(variantName))
                 {
                     productName += variantName;
                 }
             }
             if (this.LinkProducts)
             {
                 //OUTPUT NAME AS LINK TO EDIT PRODUCT PAGE
                 string url  = "~/Admin/Products/EditProduct.aspx?ProductId=" + product.Id.ToString();
                 string link = string.Format("<a href=\"{0}\" target=\"_blank\">{1}</a>", Page.ResolveUrl(url), productName);
                 phProductName.Controls.Add(new LiteralControl(link));
             }
             else
             {
                 //OUTPUT NAME
                 phProductName.Controls.Add(new LiteralControl(productName));
             }
             //SHOW INPUTS
             IList <BasketItemInput> inputs = GetCustomerInputs();
             if (inputs.Count > 0)
             {
                 InputList.DataSource = inputs;
                 InputList.DataBind();
             }
             else
             {
                 InputList.Visible = false;
             }
             //SHOW KIT PRODUCTS IF AVAILABLE, AND THE PRODUCT DOES NOT USE ITEMIZED DISPLAY
             if (!string.IsNullOrEmpty(_BasketItem.KitList) && _BasketItem.Product != null && _BasketItem.Product.Kit != null && !_BasketItem.Product.Kit.ItemizeDisplay)
             {
                 IList <BasketItem> kitProductList = GetKitProducts(_BasketItem);
                 if (kitProductList.Count > 0)
                 {
                     KitProductPanel.Visible       = true;
                     KitProductRepeater.DataSource = kitProductList;
                     KitProductRepeater.DataBind();
                 }
             }
             //SET THE KIT MEMBER LABEL
             if (_BasketItem.OrderItemType == OrderItemType.Product && _BasketItem.IsChildItem)
             {
                 BasketItem parentItem = _BasketItem.GetParentItem(true);
                 if (parentItem != null && parentItem.Product != null && parentItem.Product.Kit != null && parentItem.Product.Kit.ItemizeDisplay)
                 {
                     //SET THE WISHLIST NAME
                     KitMemberLabel.Visible = true;
                     KitMemberLabel.Text    = string.Format(KitMemberLabel.Text, parentItem.Name);
                 }
             }
             //SET THE WISHLIST LABEL
             WishlistLabel.Visible = (_BasketItem.WishlistItem != null);
             if (WishlistLabel.Visible)
             {
                 //SET THE WISHLIST NAME
                 WishlistLabel.Text = string.Format(WishlistLabel.Text, GetWishlistName(_BasketItem.WishlistItem.Wishlist));
             }
             //SET THE SHIPS TO PANEL
             Basket         basket   = _BasketItem.Basket;
             BasketShipment shipment = _BasketItem.Shipment;
             Address        address  = (shipment == null) ? null : shipment.Address;
             ShipsToPanel.Visible = (this.ShowShipTo && (address != null) && (!string.IsNullOrEmpty(address.FullName)));
             if (ShipsToPanel.Visible)
             {
                 ShipsTo.Text = address.FullName;
             }
             //SHOW GIFT WRAP
             GiftWrapPanel.Visible = (_BasketItem.WrapStyle != null);
             if (GiftWrapPanel.Visible)
             {
                 GiftWrap.Text = _BasketItem.WrapStyle.Name;
                 //GiftWrapPrice.Visible = (_BasketItem.WrapStyle.Price != 0);
                 //GiftWrapPrice.Text = string.Format("&nbsp;({0})", _BasketItem.WrapStyle.Price);
             }
             //SHOW GIFT MESSAGE
             GiftMessagePanel.Visible = (!string.IsNullOrEmpty(_BasketItem.GiftMessage));
             if (GiftMessagePanel.Visible)
             {
                 GiftMessage.Text = _BasketItem.GiftMessage;
             }
             //SHOW ASSETS
             List <AbleCommerce.Code.ProductAssetWrapper> assets = AbleCommerce.Code.ProductHelper.GetAssets(this.Page, _BasketItem.Product, _BasketItem.OptionList, _BasketItem.KitList, "javascript:window.close()");
             AssetsPanel.Visible = (this.ShowAssets && assets.Count > 0);
             if (AssetsPanel.Visible)
             {
                 AssetLinkList.DataSource = assets;
                 AssetLinkList.DataBind();
             }
             //SHOW SUBSCRIPTIONS
             SubscriptionPlan sp = _BasketItem.Product.SubscriptionPlan;
             if (sp != null && _BasketItem.IsSubscription && _BasketItem.Frequency > 0)
             {
                 // GET THE RECURRING PAYMENT MESSAGE FOR THIS PRODUCT
                 RecuringPaymentMessage.Text = AbleCommerce.Code.ProductHelper.GetRecurringPaymentMessage(_BasketItem);
                 SubscriptionPanel.Visible   = true;
             }
         }
         else
         {
             //OUTPUT NAME
             phProductName.Controls.Add(new LiteralControl(_BasketItem.Name));
             InputList.Visible         = false;
             KitProductPanel.Visible   = false;
             WishlistLabel.Visible     = false;
             ShipsToPanel.Visible      = false;
             GiftWrapPanel.Visible     = false;
             GiftMessagePanel.Visible  = false;
             AssetsPanel.Visible       = false;
             SubscriptionPanel.Visible = false;
         }
     }
     else
     {
         //NO ITEM TO DISPLAY
         this.Controls.Clear();
     }
 }
Beispiel #6
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            BasketItem basketItem = BasketItemDataSource.Load(this.BasketItemId);

            if (basketItem != null)
            {
                Product product = basketItem.Product;
                if (product != null)
                {
                    //OUTPUT THE PRODUCT NAME
                    string productName = basketItem.Name;
                    if (basketItem.ProductVariant != null)
                    {
                        string variantName = string.Format(" ({0})", basketItem.ProductVariant.VariantName);
                        if (!productName.EndsWith(variantName))
                        {
                            productName += variantName;
                        }
                    }
                    if (this.LinkProducts && product.Visibility != CatalogVisibility.Private)
                    {
                        //OUTPUT NAME AS LINK
                        string url = UrlGenerator.GetBrowseUrl(product.Id, CatalogNodeType.Product, product.Name);
                        if (!string.IsNullOrEmpty(basketItem.KitList) && !string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}&Options={3}\">{4}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.KitList, basketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (!string.IsNullOrEmpty(basketItem.KitList) && string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}\">{3}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.KitList, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (string.IsNullOrEmpty(basketItem.KitList) && !string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Options={2}\">{3}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}\">{2}</a>", Page.ResolveUrl(url), basketItem.Id, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                    }
                    else
                    {
                        //OUTPUT NAME
                        phProductName.Controls.Add(new LiteralControl(productName));
                    }

                    if (EnableFriendlyFormat)
                    {
                        phProductName.Controls.AddAt(0, new LiteralControl(string.Format("{0} of ", basketItem.Quantity)));
                        phProductName.Controls.Add(new LiteralControl(string.Format("<span class='price'>({0})</span>", basketItem.Price.LSCurrencyFormat("ulc"))));
                    }

                    //SHOW INPUTS
                    IList <BasketItemInput> inputs = GetCustomerInputs(basketItem);
                    if (inputs.Count > 0)
                    {
                        InputList.DataSource = inputs;
                        InputList.DataBind();
                    }
                    else
                    {
                        InputList.Visible = false;
                    }
                    //SHOW KIT PRODUCTS IF AVAILABLE, AND THE PRODUCT DOES NOT USE ITEMIZED DISPLAY OR FORCE KIT DISPLAY IS ON
                    if (!string.IsNullOrEmpty(basketItem.KitList) && basketItem.Product != null &&
                        basketItem.Product.Kit != null && (!basketItem.Product.Kit.ItemizeDisplay || this.ForceKitDisplay))
                    {
                        IList <BasketItem> kitProductList = GetKitProducts(basketItem, this.IgnoreKitShipment);
                        if (kitProductList.Count > 0)
                        {
                            KitProductPanel.Visible       = true;
                            KitProductRepeater.DataSource = kitProductList;
                            KitProductRepeater.DataBind();
                        }
                    }
                    //SET THE KIT MEMBER LABEL
                    if (basketItem.OrderItemType == OrderItemType.Product && basketItem.IsChildItem)
                    {
                        BasketItem parentItem = basketItem.GetParentItem(true);
                        if (parentItem != null)
                        {
                            if ((parentItem.Product != null && basketItem.Product.Kit != null && parentItem.Product.Kit.ItemizeDisplay) ||
                                basketItem.ShipmentId != parentItem.ShipmentId)
                            {
                                //SET THE WISHLIST NAME
                                KitMemberLabel.Visible = true;
                                KitMemberLabel.Text    = string.Format(KitMemberLabel.Text, parentItem.Name);
                            }
                        }
                    }
                    //SET THE WISHLIST LABEL
                    WishlistLabel.Visible = (basketItem.WishlistItem != null);
                    if (WishlistLabel.Visible)
                    {
                        //SET THE WISHLIST NAME
                        WishlistLabel.Text = string.Format(WishlistLabel.Text, GetWishlistName(basketItem.WishlistItem.Wishlist));
                    }
                    //SET THE SHIPS TO PANEL
                    Basket         basket   = basketItem.Basket;
                    BasketShipment shipment = basketItem.Shipment;
                    Address        address  = (shipment == null) ? null : shipment.Address;
                    ShipsToPanel.Visible = (this.ShowShipTo && (address != null) && (!string.IsNullOrEmpty(address.FullName)));
                    if (ShipsToPanel.Visible)
                    {
                        ShipsTo.Text = address.FullName;
                    }
                    //SHOW GIFT WRAP
                    GiftWrapPanel.Visible = (basketItem.WrapStyle != null);
                    if (GiftWrapPanel.Visible)
                    {
                        GiftWrap.Text         = basketItem.WrapStyle.Name;
                        GiftWrapPrice.Visible = (basketItem.WrapStyle.Price != 0);
                        GiftWrapPrice.Text    = string.Format("&nbsp;({0})", basketItem.WrapStyle.Price.LSCurrencyFormat("ulc"));
                    }
                    //SHOW GIFT MESSAGE
                    GiftMessagePanel.Visible = (!string.IsNullOrEmpty(basketItem.GiftMessage));
                    if (GiftMessagePanel.Visible)
                    {
                        GiftMessage.Text = basketItem.GiftMessage;
                    }
                    //SHOW ASSETS
                    List <AbleCommerce.Code.ProductAssetWrapper> assets = AbleCommerce.Code.ProductHelper.GetAssets(this.Page, basketItem.Product, basketItem.OptionList, basketItem.KitList, "javascript:window.close()");
                    AssetsPanel.Visible = (this.ShowAssets && assets.Count > 0);
                    if (AssetsPanel.Visible)
                    {
                        AssetLinkList.DataSource = assets;
                        AssetLinkList.DataBind();
                    }
                    //SHOW SUBSCRIPTIONS
                    if (this.ShowSubscription)
                    {
                        SubscriptionPlan sp = basketItem.Product.SubscriptionPlan;
                        if (sp != null && basketItem.IsSubscription && basketItem.Frequency > 0)
                        {
                            // GET THE RECURRING PAYMENT MESSAGE FOR THIS PRODUCT
                            RecurringPaymentMessage.Text = AbleCommerce.Code.ProductHelper.GetRecurringPaymentMessage(basketItem);
                            SubscriptionPanel.Visible    = true;
                        }
                    }
                }
                else
                {
                    //OUTPUT NAME
                    phProductName.Controls.Add(new LiteralControl(basketItem.Name));
                    InputList.Visible         = false;
                    KitProductPanel.Visible   = false;
                    WishlistLabel.Visible     = false;
                    ShipsToPanel.Visible      = false;
                    GiftWrapPanel.Visible     = false;
                    GiftMessagePanel.Visible  = false;
                    AssetsPanel.Visible       = false;
                    SubscriptionPanel.Visible = false;
                }
            }
            else
            {
                //NO ITEM TO DISPLAY
                this.Controls.Clear();
            }
        }