public LineItemDraft GetLineItemDraftBySku(string sku, int quantity = 1)
        {
            LineItemDraft lineItemDraft = new LineItemDraft();

            lineItemDraft.Sku      = sku;
            lineItemDraft.Quantity = quantity;
            return(lineItemDraft);
        }
        /// <summary>
        /// Get Line Item Draft, by default master variant is selected
        /// </summary>
        /// <param name="productId">product Id</param>
        /// <param name="variantId">variant Id - by default master variant Id</param>
        /// <param name="quantity">quantity of this product variant</param>
        /// <returns>line item draft</returns>
        public LineItemDraft GetLineItemDraft(string productId, int variantId = 1, int quantity = 1)
        {
            LineItemDraft lineItemDraft = new LineItemDraft();

            lineItemDraft.ProductId = productId;
            lineItemDraft.VariantId = variantId;
            lineItemDraft.Quantity  = quantity;
            return(lineItemDraft);
        }
Beispiel #3
0
        public Cart CreateCartWithLineItem(TaxMode taxMode = TaxMode.Platform, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false)
        {
            Product       product       = this.CreateProduct();
            LineItemDraft lineItemDraft = this.GetLineItemDraftBySku(product.MasterData.Current.MasterVariant.Sku, quantity: 6);
            CartDraft     cartDraft     = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress);

            cartDraft.LineItems = new List <LineItemDraft> {
                lineItemDraft
            };
            cartDraft.TaxMode = taxMode;
            Cart cart = this.CreateCart(cartDraft);

            return(cart);
        }
        public Cart CreateCartWithLineItem(TaxMode taxMode = TaxMode.Platform, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false, bool withShippingMethod = false, string customerEmail = null)
        {
            CartDraft cartDraft = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress, withShippingMethod, customerEmail);

            var taxCategoryReference = withShippingMethod
                ? this.shippingMethodsFixture.GetShippingMethodTaxCategoryByKey(cartDraft.ShippingMethod.Key)
                : null;
            Product       product       = this.CreateProduct(taxCategoryReference: taxCategoryReference);
            LineItemDraft lineItemDraft = this.GetLineItemDraftBySku(product.MasterData.Current.MasterVariant.Sku, quantity: 6);

            cartDraft.LineItems = new List <LineItemDraft> {
                lineItemDraft
            };
            cartDraft.TaxMode = taxMode;
            Cart cart = this.CreateCart(cartDraft);

            return(cart);
        }