コード例 #1
0
        protected string GetCountryImage(int countryId)
        {
            const string FLAG_HTML_FORMAT = "<span class='flag-icon flag-icon-{0}' alt='{1}' title='{1}'></span> {1}";
            var          country          = ShippingService.GetCountryById(countryId);

            if (country != null)
            {
                return(string.Format(FLAG_HTML_FORMAT, country.ISO3166Code.ToLower(), country.Name));
            }

            return(string.Empty);
        }
コード例 #2
0
        protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            int countryId = Convert.ToInt32(ddlCountry.SelectedValue);
            var country   = ShippingService.GetCountryById(countryId);

            if (country.ISO3166Code == "US")
            {
                phState.Visible = true;
            }
            else
            {
                phState.Visible = false;
            }
        }
コード例 #3
0
        private string AddToCart(int profileId, int productId, int productPriceId, string currencyCode, int quantity)
        {
            var profile   = AccountService.GetProfileById(profileId);
            var countryId = profile.GetAttribute <int>("Profile", SystemCustomerAttributeNames.CountryId, UtilityService);
            var country   = ShippingService.GetCountryById(countryId);
            var message   = CartService.ProcessItemAddition(
                profileId,
                productId,
                productPriceId,
                country.ISO3166Code,
                quantity,
                disablePhoneOrderCheck: true);

            return(message);
        }
コード例 #4
0
        private string AddToCart(int profileId, int productId, int productPriceId, string currencyCode, int quantity)
        {
            // Delete existing cart item first
            CartService.DeleteCartItemsByProfileIdAndPriceId(profileId, productPriceId, true);

            var profile   = AccountService.GetProfileById(profileId);
            var countryId = profile.GetAttribute <int>("Profile", SystemCustomerAttributeNames.CountryId, UtilityService);
            var country   = ShippingService.GetCountryById(countryId);

            var message = CartService.ProcessItemAddition(
                profileId,
                productId,
                productPriceId,
                country.ISO3166Code,
                quantity,
                QueryOfferRuleId);

            return(message);
        }
コード例 #5
0
        protected void gvTempCart_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow row;
            int         profileId   = QueryUserId;
            int         offerRuleId = QueryOfferRuleId;
            int         productPriceId;
            Country     country;

            switch (e.CommandName)
            {
            case "updateItem":
                row            = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
                productPriceId = Convert.ToInt32(e.CommandArgument);

                TextBox txtQty   = (TextBox)row.FindControl("txtQty");
                int     quantity = Convert.ToInt32(txtQty.Text.Trim());

                CartService.UpdateLineQuantityByProfileIdAndProductPriceId(profileId, productPriceId, quantity);

                country = ShippingService.GetCountryById(ShippingSettings.PrimaryStoreCountryId);

                OfferService.ProcessCartOfferByProfileId(profileId, country.ISO3166Code, offerRuleId);

                LoadCart(profileId);
                break;

            case "removeItem":
                productPriceId = Convert.ToInt32(e.CommandArgument);
                CartService.DeleteCartItemsByProfileIdAndPriceId(profileId, productPriceId, freeItemIncluded: true);
                country = ShippingService.GetCountryById(ShippingSettings.PrimaryStoreCountryId);
                OfferService.ProcessCartOfferByProfileId(profileId, country.ISO3166Code, offerRuleId);

                LoadCart(profileId);
                break;

            default:
                break;
            }

            hfCurrentPanel.Value = "test";
        }
コード例 #6
0
        protected void lbApplyTestPromoCode_Click(object sender, EventArgs e)
        {
            var profileId = QueryUserId;
            var promoCode = txtTestPromoCode.Text.Trim();

            UtilityService.SaveAttribute(profileId,
                                         "Profile",
                                         SystemCustomerAttributeNames.DiscountCouponCode,
                                         promoCode);

            int offerRuleId = QueryOfferRuleId;
            var country     = ShippingService.GetCountryById(ShippingSettings.PrimaryStoreCountryId);

            OfferService.ProcessCartOfferByProfileId(profileId, country.ISO3166Code, offerRuleId);

            LoadCart(profileId);

            hfCurrentPanel.Value = "test";

            enbTempCart.Message = "Promo code was applied successfully.";
        }
コード例 #7
0
        private Address BuildAddress()
        {
            Address address = new Address
            {
                Name          = txtName.Text,
                AddressLine1  = string.IsNullOrEmpty(txtAddrLine1.Text.Trim()) ? null : txtAddrLine1.Text.Trim(),
                AddressLine2  = string.IsNullOrEmpty(txtAddrLine2.Text.Trim()) ? null : txtAddrLine2.Text.Trim(),
                City          = string.IsNullOrEmpty(txtCity.Text.Trim()) ? null : txtCity.Text.Trim(),
                County        = string.IsNullOrEmpty(txtCounty.Text.Trim()) ? null : txtCounty.Text.Trim(),
                PostCode      = string.IsNullOrEmpty(txtPostCode.Text.Trim()) ? null : txtPostCode.Text.Trim(),
                CreatedOnDate = DateTime.Now,
                UpdatedOnDate = DateTime.Now
            };

            Country country = ShippingService.GetCountryById(Convert.ToInt32(ddlCountry.SelectedItem.Value));

            address.Country   = country;
            address.CountryId = country.Id;

            if (address.Country.ISO3166Code == "US")
            {
                USState usState = ShippingService.GetUSStateByCode(ddlState.SelectedValue);
                address.USState   = usState;
                address.USStateId = usState.Id;
            }

            var profileId   = QueryUserId;
            var isAnonymous = AccountService.GetAnonymousStatusByProfileId(profileId);

            if (isAnonymous == false)
            {
                var addressList = AccountService.GetAddressesByProfileId(profileId);
                var id          = addressList.Where(a => BothAddressesAreSame(a, address)).Select(a => a.Id).FirstOrDefault();
                address.Id = id;
            }

            return(address);
        }
コード例 #8
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            Address address = new Address();

            address.Name         = txtName.Text.Trim();
            address.AddressLine1 = txtAddrLine1.Text.Trim();
            address.AddressLine2 = txtAddrLine2.Text.Trim();
            address.City         = txtCity.Text.Trim();
            address.County       = txtCounty.Text.Trim();
            address.PostCode     = txtPostCode.Text.Trim();
            address.Country      = ShippingService.GetCountryById(Convert.ToInt32(ddlCountry.SelectedValue));
            address.CountryId    = address.Country.Id;

            if (address.Country != null && address.Country.ISO3166Code == "US")
            {
                var usState = ShippingService.GetUSStateByCode(ddlState.SelectedValue);
                address.USState   = usState;
                address.USStateId = usState.Id;
            }

            phEdit.Visible    = false;
            phAddress.Visible = true;
            InvokeChanged(address);
        }
コード例 #9
0
        private void LoadInfo(bool charged)
        {
            int orderId = QueryOrderId;

            var shippingAddress = OrderService.GetShippingAddressViewModelByOrderId(orderId);

            ltlHeaderAddress.Text = "Ship To:" + HtmlElement.BR;
            if (string.IsNullOrEmpty(shippingAddress.Name) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.Name + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.AddressLine1) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.AddressLine1 + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.AddressLine2) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.AddressLine2 + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.City) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.City + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.PostCode) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.PostCode + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.USStateName) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.USStateName + HtmlElement.BR;
            }
            if (string.IsNullOrEmpty(shippingAddress.CountryName) == false)
            {
                ltlHeaderAddress.Text += shippingAddress.CountryName + HtmlElement.BR;
            }

            ltlDeliveryAddr.Text = ltlHeaderAddress.Text;

            eohHeader.OrderId   = orderId;
            eavShipping.OrderId = orderId;

            var orderView = OrderService.GetOrderOverviewModelById(orderId);

            esnShipping.OrderOverviewModel = orderView;

            // Exclude anonymous order
            if (orderView.ProfileId > 0)
            {
                var account = AccountService.GetAccountByProfileId(orderView.ProfileId);

                if (account != null)
                {
                    eavShipping.Email        = string.IsNullOrEmpty(account.Email) ? string.Empty : account.Email;
                    eavShipping.Phone        = string.IsNullOrEmpty(account.ContactNumber) ? string.Empty : account.ContactNumber;
                    eavShipping.DisplayPhone = account.DisplayContactNumberInDespatch;

                    ltContactNumber.Text = string.Empty;
                    if (account.DisplayContactNumberInDespatch)
                    {
                        ltContactNumber.Text = string.Format("<i class='fa fa-phone' aria-hidden='true'></i> {0}", account.ContactNumber);
                    }
                }
            }

            if (orderView.PointValue > 0)
            {
                phEarnPoint.Visible = true;
                ltlPointValue.Text  = orderView.PointValue.ToString();
            }
            else
            {
                phEarnPoint.Visible = false;
            }

            var items = OrderService.GetLineItemOverviewModelListByOrderId(orderId);

            rptItems.DataSource = items;
            rptItems.DataBind();

            rptDnoteItems.DataSource = items;
            rptDnoteItems.DataBind();

            rptComments.DataSource = OrderService.GetOrderCommentOverviewModelListByOrderId(orderId, AppConstant.SHOW_MAX_COMMENT);
            rptComments.DataBind();

            if (orderView.StatusCode == OrderStatusCode.SHIPPING ||
                orderView.StatusCode == OrderStatusCode.INVOICED ||
                orderView.StatusCode == OrderStatusCode.CANCELLED ||
                orderView.StatusCode == OrderStatusCode.DISCARDED ||
                orderView.StatusCode == OrderStatusCode.PENDING ||
                orderView.StatusCode == OrderStatusCode.SCHEDULED_FOR_CANCEL ||
                orderView.StatusCode == OrderStatusCode.STOCK_WARNING)
            {
                phItems.Visible     = false;
                esnShipping.Visible = false;
            }
            else
            {
                phItems.Visible     = true;
                esnShipping.Visible = true;
            }

            var GAItems = items.Where(i => i.StatusCode == LineStatusCode.GOODS_ALLOCATED).ToList();

            int     weight        = 0;
            decimal netValue      = 0M;
            int     quantityGA    = GAItems.Select(i => i.Quantity).Sum();
            int     quantityOrder = items.Select(i => i.Quantity).Sum();

            GAItems.ForEach(delegate(LineItemOverviewModel item)
            {
                weight   += item.Weight * item.Quantity;
                netValue += (item.PriceExclTax * item.Quantity);
            });

            // Discount only if quantities match
            if (quantityOrder == quantityGA)
            {
                decimal result = netValue - orderView.DiscountValue;
                if (result > 0M)
                {
                    netValue = result;
                }
            }

            ltlWeightGrams.Text = "<input id=\"cn22Weight\" class=\"form-control\" type=\"text\" value=\"" + weight + "\" onkeyup=\"getWeightInput(event)\" />";
            ltlNetValue.Text    = "<input id=\"cn22Value\" class=\"form-control\" type=\"text\" value=\"" + orderView.CurrencyCode + " " + AdminStoreUtility.RoundPrice(netValue) + "\" onkeyup=\"getValueInput(event)\" />";

            if (GAItems.Count == 0)
            {
                lbSubmitTop.Visible    = false;
                lbSubmitBottom.Visible = false;
            }

            if (charged)
            {
                lbProcessPaymentTop.Visible = false;
                phAfterPaymentTop.Visible   = true;

                lbProcessPaymentBottom.Visible = false;
                phAfterPaymentBottom.Visible   = true;
            }
            else
            {
                lbProcessPaymentTop.Visible = true;
                phAfterPaymentTop.Visible   = false;

                lbProcessPaymentBottom.Visible = true;
                phAfterPaymentBottom.Visible   = false;

                enbInfo.Message = "This order was not fully paid. Please process payment first before proceed to packing.";
            }

            // Shipping Option ID
            // Next Day Shipping Option ID = 2
            // Local Standard Shipping Option ID = 1

            if (shippingAddress.CountryId == ShippingSettings.PrimaryStoreCountryId)
            {
                ltlFirstClass.Text    = "<input type=\"radio\" name=\"stampType\" value=\"firstClass\" checked=\"checked\" /> 1st class";
                ltlInternational.Text = "<input type=\"radio\" name=\"stampType\" value=\"international\" /> International";
            }
            else
            {
                ltlFirstClass.Text    = "<input type=\"radio\" name=\"stampType\" value=\"firstClass\" /> 1st class";
                ltlInternational.Text = "<input type=\"radio\" name=\"stampType\" value=\"international\" checked=\"checked\" /> International";
            }

            ltlCN22Date.Text  = DateTime.Now.ToString(AppConstant.DATE_FORM1);
            ltlSignature.Text = "<img src=\"/img/diana-sig.jpg\" alt=\"diana\" width=\"50\" />"; // Default
            var country = ShippingService.GetCountryById(shippingAddress.CountryId);

            ltlDeminimis.Text = country.DeminimisValue;

            ltOrderNumber.Text       = string.Format("Order # {0}", orderId);
            ltOrderNumberReturn.Text = ltOrderNumber.Text;

            int    profileId = Convert.ToInt32(HttpContext.Current.Profile.GetPropertyValue("ProfileId"));
            string email     = AccountService.GetEmailByProfileId(profileId);

            if (email.ToLower() == "*****@*****.**")
            {
                ltlSignature.Text = "<img src=\"/img/flory-sig.jpg\" alt=\"flory\" width=\"50\" />";
            }
        }
コード例 #10
0
        private void PopulateAddress(AddressOverviewModel address, out string countryName)
        {
            countryName = string.Empty;

            if (address.Name != string.Empty)
            {
                ltlName.Text = address.Name;
            }

            if (address.AddressLine1 != string.Empty)
            {
                ltlAddr1.Text = address.AddressLine1;
            }

            if (address.AddressLine2 != string.Empty)
            {
                ltlAddr2.Text = address.AddressLine2;
            }

            if (address.City != string.Empty)
            {
                ltlCity.Text = address.City;
            }

            if (address.County != string.Empty)
            {
                phCountryField.Visible = true;
                ltlCounty.Text         = address.County;
            }
            else
            {
                phCountryField.Visible = false;
            }

            if (address.PostCode != string.Empty)
            {
                ltlPostCode.Text = address.PostCode;
            }

            if (address.CountryId != 0)
            {
                Country country = ShippingService.GetCountryById(address.CountryId);

                countryName     = country.Name;
                ltlCountry.Text = country.Name;
                _countryCode    = country.ISO3166Code;
                _countryId      = country.Id;
            }
            else
            {
                _countryCode = string.Empty;
            }

            phStateField.Visible = false;
            phState.Visible      = false;
            _hasUSState          = false;
            ltlState.Text        = string.Empty;
            ltlStateCode.Text    = "-";

            if (_countryCode == US && address.USStateId != 0)
            {
                USState usState = ShippingService.GetUSStateById(address.USStateId);

                if (usState != null)
                {
                    phStateField.Visible = true;
                    phState.Visible      = true;
                    _hasUSState          = true;
                    ltlState.Text        = usState.State;
                    ltlStateCode.Text    = usState.Code;
                }
            }
        }