Nietypowy Informatyk Posted October 5, 2022 Share Posted October 5, 2022 (edited) Hi! I am working on a module, where the user can configure the product etc. I am on the step, where I can add product to cart with proper price (including parameters, custom quantity etc.) - the last thing that I have to do is to add a discount - I have already done the part of calculating a discount based on some factors, and my question is why adding specific price has no effect on products in cart. Here is what I'm trying to make: protected function addDiscount() { // class responsible for getting discount configured in backoffice $discountManager = new ApDiscounts($this->id_product); $discountValue = $discountManager->getDiscountForQuantity($this->qty); // if there is no discount then early return if (!$discountValue) { return; } // otherwise add new specific price $specificPrice = new SpecificPrice(); $specificPrice->id_product = $this->id_product; $specificPrice->id_product_attribute = (int)$this->id_product_attribute; $specificPrice->id_shop = 1; $specificPrice->id_currency = 0; $specificPrice->id_country = 20; $specificPrice->id_group = 0; $specificPrice->id_customer = 0; $specificPrice->price = '-1'; $specificPrice->from_quantity = 1; $specificPrice->reduction = 10; $specificPrice->reduction_type = 'amount'; $specificPrice->reduction_tax = 1; $specificPrice->from = date("Y-m-d H:i:s"); $specificPrice->to = date("Y-m-d H:i:s", time() + 3600); $specificPrice->add(); } Edited October 5, 2022 by Nietypowy Informatyk (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now