[[EC-CUBEめも]]

送料を計算するProcessorを以下の場所に作成します。~
app/Customize/Service/PurchaseFlow/Processor/DeliveryFeeProcessor.php

送料を100円に設定するには以下のような記述になります。~
ShoppingFlowアノテーションを書いておかないといけないのがポイントです。

 <?php
 
 namespace Customize\Service\PurchaseFlow\Processor;
 
 use Eccube\Annotation\ShoppingFlow;
 use Eccube\Entity\ItemHolderInterface;
 use Eccube\Service\PurchaseFlow\ItemHolderPreprocessor;
 use Eccube\Service\PurchaseFlow\PurchaseContext;
 
 /**
  * @ShoppingFlow
  */
 class DeliveryFeeProcessor implements ItemHolderPreprocessor
 {
     /**
      * @param ItemHolderInterface $itemHolder
      * @param PurchaseContext $context
      */
     public function process(ItemHolderInterface $itemHolder, PurchaseContext $context)
     {
         $this->updateDeliveryFeeItem($itemHolder);
     }
 
     /**
      * @param ItemHolderInterface $itemHolder
      */
     private function updateDeliveryFeeItem(ItemHolderInterface $itemHolder)
     {
         // 配送先毎に送料計算
         foreach ($itemHolder->getShippings() as $Shipping) {
             foreach ($Shipping->getOrderItems() as $item) {
                 if ($item->isDeliveryFee()) {
                     $item->setPrice(100);
                     $item->setQuantity(1);
                 }
             }
         }
     }
 }


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS