Permalink
Browse files

修正

  • Loading branch information...
1 parent bbdd5f9 commit 3694a7febcae4d9ef8425ef0078e2a19666eb310 @kurozumi-sub kurozumi-sub committed Jan 10, 2017
Showing with 28 additions and 26 deletions.
  1. +28 −26 data/class/plg_CustomerDiscountRate_SC_Product.php
@@ -34,22 +34,20 @@ class plg_CustomerDiscountRate_SC_Product extends SC_Product
public static function getDiscountRate()
{
$objCustomer = new SC_Customer_Ex();
- if($objCustomer->hasValue('discount_rate')) {
- // 割引率からかけ率に変換
+ if (!$objCustomer->hasValue('discount_rate')) {
+ $objQuery = & SC_Query_Ex::getSingletonInstance();
+ $discount_rate = $objQuery->get('discount_rate', 'plg_customer_discount_rate', 'customer_id = ?', array($_SESSION['customer']['customer_id']));
+ $objCustomer->setValue('discount_rate', $discount_rate);
+ }
+
+ if ((int) $objCustomer->getValue('discount_rate') > 0) {
return (100 - $objCustomer->getValue('discount_rate')) / 100;
} else {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $discount_rate = $objQuery->get('discount_rate', 'plg_customer_discount_rate', 'customer_id = ?', array($_SESSION['customer']['customer_id']));
- $_SESSION['customer']['discount_rate'] = $discount_rate;
-
- if($objCustomer->getValue('discount_rate')) {
- return (100 - $objCustomer->getValue('discount_rate')) / 100;
- } else {
- return 1;
- }
+ return 1;
}
+
}
-
+
/**
* 商品規格IDから商品規格を取得する.
*
@@ -61,24 +59,24 @@ public static function getDiscountRate()
public function getProductsClass($productClassId)
{
$arrProduct = parent::getProductsClass($productClassId);
-
+
// 会員の割引率取得
$rate = SC_Product_Ex::getDiscountRate();
-
+
// 割引計算と税込計算
if (!SC_Utils_Ex::isBlank($arrProduct['price01'])) {
$arrProduct['price01'] = $arrProduct['price01'] * $rate;
- $arrProduct['price01_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax($arrProduct['price01'], $arrProduct['product_id'], $productClassId);
+ $arrProduct['price01_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax($arrProduct['price01'], $arrProduct['product_id'], $productClassId);
}
if (!SC_Utils_Ex::isBlank($arrProduct['price02'])) {
$arrProduct['price02'] = $arrProduct['price02'] * $rate;
- $arrProduct['price02_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax($arrProduct['price02'], $arrProduct['product_id'], $productClassId);
+ $arrProduct['price02_inctax'] = SC_Helper_TaxRule_Ex::sfCalcIncTax($arrProduct['price02'], $arrProduct['product_id'], $productClassId);
}
return $arrProduct;
}
-
+
/**
* 商品IDを指定し、商品一覧を取得する
*
@@ -93,16 +91,17 @@ public function getProductsClass($productClassId)
public function getListByProductIds(&$objQuery, $arrProductId = array())
{
$arrProducts = parent::getListByProductIds($objQuery, $arrProductId);
-
+
// 個人サロン会員の掛率を設定する
SC_Product_Ex::setDiscountRateToProducts($arrProducts);
-
+
// 税込金額を設定する
SC_Product_Ex::setIncTaxToProducts($arrProducts);
-
+
return $arrProducts;
+
}
-
+
/**
* 商品詳細を取得する.
*
@@ -112,16 +111,17 @@ public function getListByProductIds(&$objQuery, $arrProductId = array())
public function getDetail($product_id)
{
$arrProduct = parent::getDetail($product_id);
-
+
// 個人サロン会員の掛率を設定する
SC_Product_Ex::setDiscountRateToProduct($arrProduct);
-
+
// 税込金額を設定する
SC_Product_Ex::setIncTaxToProduct($arrProduct);
return $arrProduct;
+
}
-
+
/**
* 商品情報の配列に掛率を設定する
*
@@ -133,8 +133,9 @@ public static function setDiscountRateToProducts(&$arrProducts)
foreach ($arrProducts as &$arrProduct) {
SC_Product_Ex::setDiscountRateToProduct($arrProduct);
}
+
}
-
+
/**
* 商品情報の配列に掛率を設定する
*
@@ -144,11 +145,12 @@ public static function setDiscountRateToProducts(&$arrProducts)
public static function setDiscountRateToProduct(&$arrProduct)
{
$rate = SC_Product_Ex::getDiscountRate();
-
+
$arrProduct['price01_min'] = $arrProduct['price01_min'] * $rate;
$arrProduct['price01_max'] = $arrProduct['price01_max'] * $rate;
$arrProduct['price02_min'] = $arrProduct['price02_min'] * $rate;
$arrProduct['price02_max'] = $arrProduct['price02_max'] * $rate;
+
}
}

0 comments on commit 3694a7f

Please sign in to comment.