public CartSetShippingInformationBodyResource(string shippingCode, AddressResource shippingAddress, AddressResource billingAddress = null) { this.shippingAddress = shippingAddress; this.billingAddress = billingAddress ?? shippingAddress; shippingCarrierCode = shippingCode; shippingMethodCode = shippingCode; }
/// <summary> /// Sets the shipping and billing information on a Magento cart. /// Shipping address used is based on the EA location unless the data needed is not available. In this case, data is pulled from the customer. /// Shipping method used will be the one set in App.config. If that shipping method cannot be used for the cart specified, an exception will occur. /// </summary> /// <param name="cartId">Identifier for cart to set information on.</param> /// <param name="magentoRegion">Region information for address</param> /// <param name="eaLocation">Location information for address</param> /// <param name="customer">Customer for address information</param> public void SetShippingAndBillingInformationForCart(int cartId, RegionResource magentoRegion, LocationResource eaLocation, CustomerResource customer) { AddressResource shippingAddress; if (magentoRegion != null) { shippingAddress = new AddressResource(magentoRegion, eaLocation, customer); } else { shippingAddress = new AddressResource(customer); } //Verfiy that shipping code matches App.config file var shippingInformation = new CartSetShippingInformationResource(ConfigReader.MagentoShippingCode, shippingAddress); _magentoCartController.SetShippingInformation(cartId, shippingInformation); if (_magentoCartController.GetShippingMethods(cartId).FirstOrDefault(x => x.method_code == ConfigReader.MagentoShippingCode) == null) { throw new Exception(string.Format("Unable to add shipping information to cart {0}. Ensure that shipping code {1} is valid for this cart.", cartId, ConfigReader.MagentoShippingCode)); } }
public CartSetShippingInformationResource(string shippingCode, AddressResource shippingAddress, AddressResource billingAddress = null) { addressInformation = new CartSetShippingInformationBodyResource(shippingCode, shippingAddress, billingAddress); }