質問 > フロント機能 > 注文時にポイント付与を拡大方法 |
フロント機能
スレッド表示 | 古いものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
umebius |
投稿日時: 2020/9/23 19:22
対応状況: −−−
|
神 登録日: 2016/7/22 居住地: 投稿: 2085 |
Re: 注文時にポイント付与を拡大方法 すみません、あとはクラス継承しているようですがAddPointProcessorのvalidateが呼ばれるのは
AddPointProcessorCustomizer に validateを書いてないからではないですかね? |
umebius |
投稿日時: 2020/9/23 19:06
対応状況: −−−
|
神 登録日: 2016/7/22 居住地: 投稿: 2085 |
Re: 注文時にポイント付与を拡大方法 @ShoppingFowと言うアノテーションつけるか、
purchaseflow.yamlでeccube.purchase.flow.shopping.holder_post_validatorsの'@Eccube\Service\PurchaseFlow\Processor\AddPointProcessor' を差し替えるかしないと呼ばれないですね。 参考 https://xoops.ec-cube.net/modules/newbb/viewtopic.php?viewmode=flat&order=DESC&topic_id=23483&forum=2
|
start |
投稿日時: 2020/9/23 14:01
対応状況: −−−
|
一人前 登録日: 2017/11/9 居住地: 投稿: 109 |
注文時にポイント付与を拡大方法 商品を注文時のポイント付与機能を拡大したいです。
今以下の対応してもいけないでした。何か足りないでしょうか。教えて貰いませか。 1) AddPointProcessorCustomizer.phpファイルを作成しました。 app/Customize/Service/PurchaseFlow/Processor/AddPointProcessorCustomizer.php 中身は: <?php /* * This file is part of EC-CUBE * * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. * * http://www.ec-cube.co.jp/ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Customize\Service\PurchaseFlow\Processor; use Eccube\Service\PurchaseFlow\Processor\AddPointProcessor; use Eccube\Entity\BaseInfo; use Eccube\Entity\ItemHolderInterface; use Eccube\Entity\ItemInterface; use Eccube\Entity\Order; use Eccube\Repository\BaseInfoRepository; use Eccube\Service\PurchaseFlow\ItemHolderPostValidator; use Eccube\Service\PurchaseFlow\PurchaseContext; /** * 加算ポイント. */ class AddPointProcessorCustomizer extends AddPointProcessor { /** * 付与ポイントを計算. * * @param ItemHolderInterface $itemHolder * * @return int */ private function calculateAddPoint(ItemHolderInterface $itemHolder) { $basicPointRate = $this->BaseInfo->getBasicPointRate(); // 明細ごとのポイントを集計 $totalPoint = array_reduce($itemHolder->getItems()->toArray(), function ($carry, ItemInterface $item) use ($basicPointRate) { $pointRate = $item->isProduct() ? $item->getProductClass()->getPointRate() : null; if ($pointRate === null) { $pointRate = $basicPointRate; } echo 'testing...'; die(); // TODO: ポイントは税抜き分しか割引されない、ポイント明細は税抜きのままでいいのか? $point = 0; if ($item->isPoint()) { $point = round($item->getPrice() * ($pointRate / 100)) * $item->getQuantity(); // Only calc point on product } elseif ($item->isProduct()) { // ポイント = 単価 * ポイント付与率 * 数量 $point = round($item->getPrice() * ($pointRate / 100)) * $item->getQuantity(); } elseif($item->isDiscount()) { $point = round($item->getPrice() * ($pointRate / 100)) * $item->getQuantity(); } return $carry + $point; }, 0); return $totalPoint < 0 ? 0 : $totalPoint; } } 2)app/config/eccube/packages/purchaseflow.yaml、 app/config/eccube/services_test.yaml それぞれで前のパスを新規作成したファイルで変更しました。 動作確認したらAddPointProcessorCustomizer.phpのcalculateAddPointではなくsrc/Eccube/Service/PurchaseFlow/Processor/AddPointProcessor.phpのcalculateAddPoint関数を呼んでいます。 ▼テンプレート [EC-CUBE] EC-CUBEのバージョン、新規インストールかアップデートか、等 [レンタルサーバ] レンタルサーバ名 [OS] 使用しているOS名、バージョン [PHP] 使用しているPHPのバージョン [データベース] 使用しているDB名、バージョン [WEBサーバ] 使用しているWEBサーバ名、バージョン [ブラウザ] 使用しているブラウザ名、バージョン [導入プラグインの有無] あれば導入プラグインを記載 [カスタマイズの有無] あればカスタマイズ内容を記載(できるだけ具体的に) [現象] 再現手順や、どのような現象が発生しているかなど、具体的に |
スレッド表示 | 古いものから | 前のトピック | 次のトピック | トップ |