Prestashop 1.6
Hi!
I have to estimate the cart value based on a set of product. For this I have created a custom controller, in which controller I have created a new cart
Quote
$cart = new Cart();
$cart->id_lang = (int)$this->context->cookie->id_lang;
$cart->id_currency = (int)$this->context->cookie->id_currency;
$cart->id_guest = (int)$this->context->cookie->id_guest;
$cart->id_shop_group = (int)$this->context->shop->id_shop_group;
$cart->id_shop = $this->context->shop->id;
if ($this->context->cookie->id_customer) {
$cart->id_customer = (int)$this->context->cookie->id_customer;
$cart->id_address_delivery = (int)Address::getFirstCustomerAddressId($cart->id_customer);
$cart->id_address_invoice = (int)$cart->id_address_delivery;
} else {
$cart->id_address_delivery = 0;
$cart->id_address_invoice = 0;
}
$cart->save();
$this->context->cart = $cart;
CartRule::autoAddToCart($this->context);
How can I add products to this cart to know what the total amount of the basket will be?
Also, how can I make sure that all cart rules that are valid for this cart are deducted from the total?