-3

Currently I am working on a E-Commerce Website, I Need to Implement these Offers on add to cart as the Products are being added, the Price should be discounted according to the Offer Provided. The Offers are as follows:

  • Offer 1- Buy one get one free,
  • Offer 2- 50% off on more than 2000 buy,
  • Offer 3- 30% off on selecting more than 2 products to add to the cart.

I have made the E commerce website everything is fine but just don't know how to use the Offer logic and though tried multiple things but nothing worked as it should.

The offer must automatically work on cart as soon as the products are added and before payment gateway the discount should work and get deducted.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • What have you tried yourself? Where exactly are you stuck in your own attempt? – petezurich Nov 05 '22 at 17:57
  • I actually need code for discount to be applied on the cart as mentioned above, Simply I just need code for how to implement discount on cart after adding multiple products in cart as soon as someone adds product in cart the discount coupon should start working and the amount gets dicounted as per the offer . – Mr_developer. Nov 05 '22 at 18:09

1 Answers1

-1

idk how are your models and what's exactly your problem but let's say price_all is a field in your cart model and count is how many products of one type are in cart. for Offer 1 easily you can divide price(this is not price_all this field belongs to your product) into 2.or you can just double the count and I think the second way is better. for Offer 2 you can add an if to check if price_all is more than 2000 or not. for offer 3 you can check if the count is more than 2 or not easily. you can check all of this in save() function of your model or you can make a presave signal for that.if you don't know how just read the docs.