Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

セッションに保存される配送商品の不要なデータを削除するように #1021

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/class/helper/SC_Helper_Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ public function setShipmentItemTemp($shipping_id, $product_class_id, $quantity)

if (empty($arrItems['productsClass'])) {
$product = &$objProduct->getDetailAndProductsClass($product_class_id);
// セッション変数のデータ量を抑制するため、一部の商品情報を切り捨てる
$objCartSession = new SC_CartSession_Ex();
$objCartSession->adjustSessionProductsClass($product);
$arrItems['productsClass'] = $product;
}
$arrItems['price'] = $arrItems['productsClass']['price02'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ protected function setUp(): void
$this->productsClass = $this->objQuery->getRow('*', 'dtb_products_class', 'product_id = ?', [$this->product_id]);

$_SESSION['shipping']['1001']['shipment_item'] = [
'1001' => ['productsClass' => ['price02' => 9000]],
];
'1001' => ['productsClass' => ['price02' => 9000]],
];
$this->helper = new SC_Helper_Purchase_Ex();
}

Expand All @@ -65,36 +65,52 @@ public function testSetShipmentItemTemp製品情報が既に存在する場合
$this->helper->setShipmentItemTemp('1001', '1001', 10);

$this->expected = [
'shipping_id' => '1001',
'product_class_id' => '1001',
'quantity' => 10,
'price' => 9000,
'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax(90000),
'productsClass' => ['price02' => 9000],
];
'shipping_id' => '1001',
'product_class_id' => '1001',
'quantity' => 10,
'price' => 9000,
'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax(90000),
'productsClass' => ['price02' => 9000],
];
$this->actual = $_SESSION['shipping']['1001']['shipment_item']['1001'];

$this->verify();
}

public function testSetShipmentItemTemp製品情報が存在しない場合DBから取得した値が反映される()
public function testSetShipmentItemTemp製品情報が存在しない場合DBから取得した値が反映され不要な情報は削除される()
{
$quantity = 10;
$this->helper->setShipmentItemTemp('1001', $this->productsClass['product_class_id'], $quantity);

$objProduct = new SC_Product_Ex();
$arrProduct = $objProduct->getDetailAndProductsClass($this->productsClass['product_class_id']);
$this->expected = [
'shipping_id' => '1001',
'product_class_id' => $this->productsClass['product_class_id'],
'quantity' => $quantity,
'price' => $this->productsClass['price02'],
'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax($this->productsClass['price02']) * $quantity,
];
'shipping_id' => '1001',
'product_class_id' => $this->productsClass['product_class_id'],
'quantity' => $quantity,
'price' => $this->productsClass['price02'],
'total_inctax' => SC_Helper_TaxRule_Ex::sfCalcIncTax($this->productsClass['price02']) * $quantity,
'productsClass' => [
'product_id' => $arrProduct['product_id'],
'product_class_id' => $arrProduct['product_class_id'],
'name' => $arrProduct['name'],
'price02' => $arrProduct['price02'],
'point_rate' => $arrProduct['point_rate'],
'main_list_image' => $arrProduct['main_list_image'],
'main_image' => $arrProduct['main_image'],
'product_code' => $arrProduct['product_code'],
'stock' => $arrProduct['stock'],
'stock_unlimited' => $arrProduct['stock_unlimited'],
'sale_limit' => $arrProduct['sale_limit'],
'class_name1' => $arrProduct['class_name1'],
'classcategory_name1' => $arrProduct['classcategory_name1'],
'class_name2' => $arrProduct['class_name2'],
'classcategory_name2' => $arrProduct['classcategory_name2'],
],
];
$result = $_SESSION['shipping']['1001']['shipment_item'][$this->productsClass['product_class_id']];
unset($result['productsClass']);
$this->actual = $result;

$this->verify();
}

// ////////////////////////////////////////
}
Loading