app/Plugin/QuantityDiscountDx/Service/PurchaseFlow/Processor/PriceResetShippingPreprocessor.php line 66

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright(c) 2019 SYSTEM_KD
  4.  * Date: 2019/05/12
  5.  */
  6. namespace Plugin\QuantityDiscountDx\Service\PurchaseFlow\Processor;
  7. use Eccube\Entity\ItemHolderInterface;
  8. use Eccube\Entity\Order;
  9. use Eccube\Service\PurchaseFlow\ItemHolderPreprocessor;
  10. use Eccube\Service\PurchaseFlow\PurchaseContext;
  11. use Plugin\QuantityDiscountDx\Service\ConfigService;
  12. use Plugin\QuantityDiscountDx\Service\QuantityDiscountService;
  13. class PriceResetShippingPreprocessor implements ItemHolderPreprocessor
  14. {
  15.     protected $configService;
  16.     /** @var QuantityDiscountService  */
  17.     protected $quantityDiscountService;
  18.     public function __construct(
  19.         ConfigService $configService,
  20.         QuantityDiscountService $quantityDiscountService
  21.     )
  22.     {
  23.         $this->configService $configService;
  24.         $this->quantityDiscountService $quantityDiscountService;
  25.     }
  26.     /**
  27.      * 受注データ調整処理。
  28.      *
  29.      * @param ItemHolderInterface $itemHolder
  30.      * @param PurchaseContext $context
  31.      */
  32.     public function process(ItemHolderInterface $itemHolderPurchaseContext $context)
  33.     {
  34.         if(ConfigService::DISCOUNT_MODE_DIRECT ==
  35.             $this->configService->getKeyInteger(ConfigService::SETTING_KEY_MODE)) {
  36.             // 直接値引+値引き前送料無料での判定の場合の送料無料判定後に値引く
  37.             if(ConfigService::DISCOUNT_BEFORE_PRICE ==
  38.                 $this->configService->getKeyInteger(ConfigService::SETTING_KEY_DELIVERY_FEE_MODE)) {
  39.                 if ($itemHolder instanceof Order) {
  40.                     $Order $itemHolder;
  41.                     foreach ($Order->getShippings() as $shipping) {
  42.                         foreach ($shipping->getProductOrderItems() as $item) {
  43.                             if($this->quantityDiscountService->isDiscount($item)) {
  44.                                 $discountPrice $this->quantityDiscountService->getProductClassPrice($item);
  45.                                 $item->setPrice($discountPrice);
  46.                             }
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.             return;
  52.         }
  53.         // 金額を元に戻す
  54.         dump('金額を元に戻す');
  55.         if($itemHolder instanceof Order) {
  56.             //dump($itemHolder);
  57.             $Order $itemHolder;
  58.             foreach ($Order->getShippings() as $shipping) {
  59.                 //dump($shipping);
  60.                 foreach ($shipping->getProductOrderItems() as $item) {
  61.                     //dump($item);
  62.                     
  63.                     //20240918@hanari オプション設定がある場合は変更しない
  64.                     if(method_exists($item,'getOptionSerial')){
  65.                         dump("オプション設定がある場合は変更しない",$item);
  66.                     }else{
  67.                         dump("オプション設定がない場合変更");
  68.                         $realPrice $item->getProductClass()->getPrice02();
  69.                         $item->setPrice($realPrice);
  70.                         dump($item);
  71.                     }
  72.                 }
  73.             }
  74.         }
  75.     }
  76. }