Skip to main content

Overview

The Akatus.Carrinho.Produto class represents a product in the shopping cart. Each transaction can include between 1 and 100 products.

Properties

Codigo
string
required
Product code for internal identification. Maximum 70 characters.
Descricao
string
required
Product description. Maximum 255 characters.
Quantidade
int
required
Quantity of this product being purchased.
Preco
decimal
required
Unit price of the product. Decimal values should use period as separator (e.g., 49.90).
Peso
decimal
Product weight in kilograms. Decimal values should use period as separator.
Frete
decimal
Shipping cost for this product. Decimal values should use period as separator.
Desconto
decimal
Discount amount for this product. Decimal values should use period as separator.

Usage Example

using Akatus.Carrinho;

// Create a shopping cart
var carrinho = new Carrinho();

// Add a product
var produto1 = new Produto
{
    Codigo = "LAPTOP001",
    Descricao = "Laptop Dell Inspiron 15",
    Quantidade = 1,
    Preco = 2499.90M,
    Peso = 2.5M,
    Frete = 50.00M,
    Desconto = 100.00M
};
carrinho.Produtos.Add(produto1);

// Add another product
var produto2 = new Produto
{
    Codigo = "MOUSE001",
    Descricao = "Wireless Mouse Logitech MX Master 3",
    Quantidade = 2,
    Preco = 399.90M,
    Peso = 0.3M,
    Frete = 15.00M,
    Desconto = 0M
};
carrinho.Produtos.Add(produto2);

// Add a product with minimal information
var produto3 = new Produto
{
    Codigo = "KEYB001",
    Descricao = "Mechanical Keyboard",
    Quantidade = 1,
    Preco = 599.00M
};
carrinho.Produtos.Add(produto3);

// Total products in cart: 3 items
Console.WriteLine($"Total items in cart: {carrinho.Produtos.Count}");

// Calculate total value
var total = carrinho.Produtos.Sum(p => 
    (p.Preco * p.Quantidade) + p.Frete - p.Desconto
);
Console.WriteLine($"Cart total: R$ {total:F2}");

Notes

  • Product-level shipping and discount are optional. You can also specify these values at the transaction level using the Transacao class.
  • When both product-level and transaction-level values are specified, they are combined in the final calculation.
  • All decimal values are automatically formatted with period as decimal separator when sent to the API.

Build docs developers (and LLMs) love