Hi Benyamin,
Here is peace of code that allows you to add products to shopping cart:
// Gets a product to add to the shopping cart
SKUInfo product = SKUInfoProvider.GetSKUs()
.WhereEquals("SKUName", "NewProduct")
.WhereNull("SKUOptionCategoryID")
.FirstObject;
if (product != null)
{
// Gets the current shopping cart
ShoppingCartInfo cart = ECommerceContext.CurrentShoppingCart;
// Creates the shopping cart in the database if it does not exist yet
if (cart.ShoppingCartID == 0)
{
ShoppingCartInfoProvider.SetShoppingCartInfo(cart);
}
// Prepares a shopping cart item representing 1 unit of the product
ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID, 1);
ShoppingCartItemInfo cartItem = ShoppingCartInfoProvider.SetShoppingCartItem(cart, parameters);
// Saves the shopping cart item to the shopping cart
ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem);
// Evaluates and recalculates the shopping cart (discounts, shipping, price totals, etc).
cart.Evaluate();
}
I took this code from Kentico 11 documentation. You can find more on this link.
Best regards,
Dragoljub