[EC-CUBE] 4.0.4
[レンタルサーバ] AWS
[OS] Linux
[PHP] 7.3.14
[データベース] MySQL 5.7.28
[WEBサーバ] Apache/2.4.25
[ブラウザ] Chrome
[現象]
まとめ売りのロジックをおかじさんの下記URLを参考に作成したのですが
https://qiita.com/okazy/items/47eb40bb15a413980870「ご注文手続き画面」で「割引」というカテゴライズで伝票で表示されるため
「まとめ売り値引き」として伝票に「割引」とは別にに表示させたいのです。
どのようにおこなえばえばよろしいでしょうか?
/src/Eccube/Entity/Master/OrderItemType.php
と
mtb_order_item_typeに
「まとめ売り値引き」を追加したのですが
ご注文手続き画面で表示されませんでした。
下記まとめ売りの関数です。
/**
* まとめ売り割引計算処理
*
* @param ItemInterface $item カート内の商品情報
* @return int $discountSubTotalPrice まとめ売り小計値引き額
*/
function BandleSaleDiscountCalc($item){
$discountSubTotalPrice = 0; //まとめ売り小計値引額
//まとめ売り個数と割引率パターン
$arrayMultiDiscount =
[
107=>[//まとめ売り対象品番
50=>[1,40],//まとめ売り個数=>[割引率]
30=>[1,30],//まとめ売り個数=>[割引種類(1=定率割引2=定額割引),割引率or割引金額]
10=>[1,20],
8=>[2,7200],
6=>[2,5400],
4=>[2,3600],
2=>[2,1800]
],
108=>[
50=>[1,40],
30=>[1,30],
10=>[1,20],
8=>[2,7200],
6=>[2,5400],
4=>[2,3600],
2=>[2,1800]
],
106=>[
50=>[1,40],
30=>[1,30],
10=>[1,20],
8=>[2,7200],
6=>[2,5400],
4=>[2,3600],
2=>[2,1800]
]
];
$productClass = $item->getProductClass();
if($productClass){
$product = $productClass->getProduct(); //商品情報
$productId = $product->getId(); //商品ID
$productSaleType = $productClass->getSaleType(); //販売種別(※今後販売種別で処理分けする場合用)
$productQuantity = intVal($item->getQuantity()); //対象商品の注文個数
$productPrice = $item->getPrice(); //対象商品の単価(税抜)
//まとめ売り個数と割引率パターンを回して対象の商品IDがカートに入っているか確認
foreach ($arrayMultiDiscount as $targetProductId => $arrayDiscountPattern) {
if($productId == $targetProductId){
foreach($arrayDiscountPattern as $key => $arrayValue){
//まとめ売り個数と割引率を変数に入れる
$discountQuantityLimit = $key; //割引条件の個数
$discountType = $arrayValue[0]; //割引種類(1=定率割引2=定額割引)
$discountValue = $arrayValue[1]; //定率割引の時は割引率or定額割引の時は割引金額
//対象の商品がまとめ売りの個数に当てはまれば割引金額の計算をおこなう
if($productQuantity >= $discountQuantityLimit){
if($discountType == 1){//1の場合、定率割引の処理
$discountSubTotalPrice += intVal((intVal($productPrice*1.1)*$discountValue)/100)*$productQuantity;
}else{//1以外の場合、定額割引の処理
$discountSubTotalPrice += intVal($discountValue);
}
break;
}
}
}
}
}
return $discountSubTotalPrice;
}