Ejemplo n.º 1
0
        public oShipStationCreateLabelRequest GetShipStationCreateLabelRequestByExternalRef(long external_ref, long? orderId)
        {
            oShipStationCreateLabelRequest o = new oShipStationCreateLabelRequest();
            List<customsItems> Custom = new List<customsItems>();
            oShipInternational intl = new oShipInternational();

            using (var dc = new stylusDataContext())
            {
                ISingleResult<sp_get_order_by_external_refResult> res = dc.sp_get_order_by_external_ref(external_ref);
                foreach (sp_get_order_by_external_refResult ret in res)
                {
                    o.orderId = orderId;

                    if (ret.shipping_method.ToLower().Trim() == "standard" && ret.shipping_country_code == "US")
                    {
                        o.carrierCode = "ups";
                        o.serviceCode = "expedited_mail_innovations";
                    }

                    if (ret.shipping_method.ToLower().Trim() == "express" && ret.shipping_country_code == "US")
                    {
                        o.carrierCode = "ups";
                        o.serviceCode = "ups_2nd_day_air";
                    }

                    if (ret.shipping_method.ToLower().Trim() == "standard" && ret.shipping_country_code != "US")
                    {
                        o.carrierCode = "apc";
                        o.serviceCode = "apc_priority_ddu";
                    }

                    if (ret.shipping_method.ToLower().Trim() == "express" && ret.shipping_country_code != "US")
                    {
                        o.carrierCode = "ups";
                        o.serviceCode = "ups_worldwide_saver";
                    }

                    o.packageCode = "package";
                    if (o.serviceCode == "expedited_mail_innovations")
                    {
                        o.packageCode = "mi_irregulars";
                    }
                    else
                    {
                        o.packageCode = "package";
                    }

                    o.confirmation = "delivery";
                    o.shipDate = DateTime.Now.ToString();

                    weight w = new weight();
                    w.units = "ounces";
                    if (ret.size == "XS")
                    {
                        w.value = 8 * ret.quantity;
                    }
                    if (ret.size == "SMALL")
                    {
                        w.value = 8 * ret.quantity;
                    }
                    if (ret.size == "MEDIUM")
                    {
                        w.value = 9 * ret.quantity;
                    }
                    if (ret.size == "LARGE")
                    {
                        w.value = 8 * ret.quantity;
                    }
                    if (ret.size == "XL")
                    {
                        w.value = 10 * ret.quantity;
                    }
                    if (ret.size == "2XL")
                    {
                        w.value = 10 * ret.quantity;
                    }
                    if (ret.size == "3XL")
                    {
                        w.value = 11 * ret.quantity;
                    }

                    o.weight = w;

                    if (ret.shipping_country_code != "US")
                    {
                        intl.contents = "merchandise";
                        intl.nonDelivery = "return_to_sender";
                        customsItems c = new customsItems();
                        c.description = ret.description;
                        c.quantity = ret.quantity;
                        c.value = 14 * ret.quantity;
                        c.harmonizedTariffCode = "";
                        c.countryOfOrigin = "US";
                        Custom.Add(c);
                        intl.customsItems = Custom;
                        o.internationalOptions = intl;
                    }

                    o.testLabel = false;
                }
            }
            return o;
        }
Ejemplo n.º 2
0
        public oShipStationCreateOrderRequest GetShipStationCreateOrderRequestByExternalRef(long external_ref)
        {
            oShipStationCreateOrderRequest o = new oShipStationCreateOrderRequest();
            billTo b = new billTo();
            shipTo s = new shipTo();
            List<customsItems> Custom = new List<customsItems>();
            oShipInternational intl = new oShipInternational();
            using (var dc = new stylusDataContext())
            {
                ISingleResult<sp_get_order_by_external_refResult> res = dc.sp_get_order_by_external_ref(external_ref);
                foreach (sp_get_order_by_external_refResult ret in res)
                {
                    o.orderNumber = external_ref.ToString();
                    o.orderDate = ret.sale_datetime.ToString();

                    o.orderStatus = "awaiting_shipment";

                    b.name = "Your department.";
                    b.company = "Your company";
                    b.street1 = "Your address";
                    b.city = "city";
                    b.state = "ST";
                    b.postalCode = "06902";
                    b.country = "US";
                    b.phone = "888-888-5555";
                    b.residential = false;

                    o.billTo = b;

                    shipTo st = new shipTo();
                    st.name = ret.customer_name;
                    st.company = null;
                    st.street1 = ret.shipping_address_1;
                    st.street2 = ret.shipping_address_2;
                    //st.street3 = ret.shipping_address_3;
                    if (ret.shipping_country_code != "US")
                    {
                        intl.contents = "merchandise";
                        intl.nonDelivery = "return_to_sender";
                        customsItems c = new customsItems();
                        c.description = ret.description;
                        c.quantity = ret.quantity;
                        c.value = 14 * ret.quantity;
                        c.harmonizedTariffCode = "";
                        c.countryOfOrigin = "US";
                        Custom.Add(c);
                        intl.customsItems = Custom;
                        o.internationalOptions = intl;
                    }

                    st.city = ret.shipping_address_3;
                    st.state = ret.shipping_address_4;
                    st.postalCode = ret.shipping_postcode;
                    st.country = ret.shipping_country_code;
                    st.phone = ret.phone;
                    st.residential = true;

                    o.shipTo = st;
                }
                return o;
            }
            return o;
        }