1

デフォルトでは、Opencart の報酬ポイントは、税込みの製品では機能しないようです。ポイントで製品を購入すると、製品の価格が差し引かれますが、税金は含まれないため、その「無料」製品の支払いに VAT が残ります。この方法では、報酬ポイントで無料の製品を取得できず、請求書が誤って生成されます。

model/total/reward.php を編集して商品の税を含めようとしています! 修正のスニペットを見つけましたが、それは古いバージョン用で、私の 1.5.5.1 では動作しないようです。

誰か見てもらえますか?

これが見つかったスニペットです

    <?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']) {
                     $taxes[$product['tax_class_id']] -= ($product['total'] / 100 * $this->tax->getRates($product['tax_class_id'])) - (($product['total'] - $discount) / 100 * $this->tax->getRates($product['tax_class_id']));
                  }
               }

               $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'] . "', order_id = '" . (int)$order_info['order_id'] . "', description = '" . $this->db->escape(sprintf($this->language->get('text_order_id'), (int)$order_info['order_id'])) . "', points = '" . (float)-$points . "', date_added = NOW()");            
      }
   }      
}
?>

これが元のモデル/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()");            
      }
   }      
}
?>

ありがとう !

4

1 に答える 1