Post by mruoppolo » Tue Jun 09, 2015 12:22 pm

Hi, how are you?

Well, i'm having a issue with my special promotions vqmod, when i bought it, the module wasn't working, so i asked for help to a friend of mine and he could help to make it works, but the module is applying the discount duplicated. If the client buy US$100 and the discount should be US$50, when clients apply the code it will give US$100 discount.

Im very new on opencart, and i really don't know much about it, buy im a PHP developer and i think it could help me to find the issue.

I've found this code and i think this is applying the discount, do you know if the problem is here??

Code: Select all

            $this->load->model('module/special_promotions');
            $sp_hints = $this->model_module_special_promotions->getHints($result['product_id']);
            if ($sp_hints) {
                foreach ($sp_hints as $sp_hint) {
                    if ($sp_hint['show_as_special']) {
                        if ($special) {
                            $price = $special;
                            if ($sp_hint['discount_method'] == '1') {
                                $special = $this->currency->format($this->tax->calculate(max(0, $result['special'] - $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $result['special'] - $sp_hint['discount_amount']));
                                }
                            } elseif ($sp_hint['discount_method'] == '2') {
                                $special = $this->currency->format($this->tax->calculate(max(0, $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $sp_hint['discount_amount']));
                                }
                            } else {
                                $special = $this->currency->format($this->tax->calculate(max(0, $result['special'] - $result['special'] / 100 * $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $result['special'] - $result['special'] / 100 * $sp_hint['discount_amount']));
                                }
                            }
                        } elseif ($price) {
                            if ($sp_hint['discount_method'] == '1') {
                                $special = $this->currency->format($this->tax->calculate(max(0, $result['price'] - $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $result['price'] - $sp_hint['discount_amount']));
                                }
                            } elseif ($sp_hint['discount_method'] == '2') {
                                $special = $this->currency->format($this->tax->calculate(max(0, $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $sp_hint['discount_amount']));
                                }
                            } else {
                                $special = $this->currency->format($this->tax->calculate(max(0, $result['price'] - $result['price'] / 100 * $sp_hint['discount_amount']), $result['tax_class_id'], $this->config->get('config_tax')));
                                if (!empty($tax)) {
                                    $tax = $this->currency->format((float)max(0, $result['price'] - $result['price'] / 100 * $sp_hint['discount_amount']));
                                }
                            }
                        }
                        break;
                    }
                }
            }
            
Thank you very much, i really need to make it works :D

Newbie

Posts

Joined
Tue Jun 09, 2015 12:12 pm
Who is online

Users browsing this forum: No registered users and 6 guests