Jump to content

Product with zero price (100% discount) in the Cart


mytrash

Recommended Posts

Hello I am developing module which allows user to buy product with zero price when he buys another (expensive) product. I am able to find that user is adding expensive product to cart. At this moment I would like to add another product to cart automatically with zero price.

 

Example:

There are 3 products on my stock:

id name price

1 Bottle of vine 100 Eur

2 Table 200 Eur

3 Expensive Car 10000 Eur

 

You can buy each product independently, but when you buy Expensive Car I would like to add Bottle of vine with ZERO price. At this time I am able to add Bottle of vine (I am using $cart->updateQty method), but the price of the vine in the cart is 100 Eur :-( and I need 0 Eur.

 

Than you for your help.

Myth

Link to comment
Share on other sites

to get a list of discounts available for a customer, you would do something like this

$discounts = Discount::getVouchersForProduct($id_category_current, (int)$id_customer);

 

the above will return you an array of discount information, so you will need to find the discount you want to apply.

once you find it, then to add a discount to the cart, you would do something like this.

$cart->addDiscount($id_discount);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...