Jump to content
Sign in to follow this  
EvgeniyOC

[Решено] Курс Rewards Points (Бонусных баллов) к цене

Recommended Posts

Доброго времени суток форумчане! Пожалуйста, подскажите в каком файле opencart объявлена формула считающая отношение бонусных баллов к цене?

 

Пример (как есть):

 

                 Сумма в ББ: 515           Сумма: 250.00руб Бонусные баллы (100): -48.54руб Итого: 201.46руб

 

Пример (как хотелось бы):

                 Сумма в ББ: 515           Сумма: 250.00руб Бонусные баллы (100): -9.00руб Итого: 241.00руб

 

Хотелось бы чтобы клиенту необходимо было доплатить вместо 201 рубля - 241 рублей. т.е чтобы при использовании 100 бонусных баллов скидка составила: 9 рублей. 

Share this post


Link to post
Share on other sites

Пожалуйста, подскажите в каком файле opencart объявлена формула считающая отношение бонусных баллов к цене?

catalog/model/total/reward.php

Share this post


Link to post
Share on other sites

catalog/model/total/reward.php

 

Спасибо, тему можно закрывать. 

 

файл: catalog/model/total/reward.php

<?php
class ModelTotalReward extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		if (isset($this->session->data['reward'])) {
			$this->language->load('total/reward');

			$points = $this->customer->getRewardPoints();

			if ($this->session->data['reward'] <= $points) {
				$discount_total = 0;

				$points_total = 0;

				foreach ($this->cart->getProducts() as $product) {
					if ($product['points']) {
						$points_total += $product['points'];
					}
				}	

				$points = min($points, $points_total);

				foreach ($this->cart->getProducts() as $product) {
					$discount = 0;

					if ($product['points']) {
						$discount = $product['total'] * ($this->session->data['reward'] / $points_total);

						if ($product['tax_class_id']) {
							$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);

							foreach ($tax_rates as $tax_rate) {
								if ($tax_rate['type'] == 'P') {
									$taxes[$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
								}
							}	
						}
					}

					$discount_total += $discount;
				}

				$total_data[] = array(
					'code'       => 'reward',
					'title'      => sprintf($this->language->get('text_reward'), $this->session->data['reward']),
					'text'       => $this->currency->format(-$discount_total),
					'value'      => -$discount_total,
					'sort_order' => $this->config->get('reward_sort_order')
				);

				$total -= $discount_total;
			} 
		}
	}

	public function confirm($order_info, $order_total) {
		$this->language->load('total/reward');

		$points = 0;

		$start = strpos($order_total['title'], '(') + 1;
		$end = strrpos($order_total['title'], ')');

		if ($start && $end) {  
			$points = substr($order_total['title'], $start, $end - $start);
		}	

		if ($points) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$order_info['customer_id'] . "', description = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', points = '" . (float)-$points . "', date_added = NOW()");				
		}
	}		
}
?>

26 строка:

$discount = $product['total'] * ($this->session->data['reward'] / $points_total);

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.