Eccube\Entity\Order::setPref PHP Метод

setPref() публичный Метод

Set Pref
public setPref ( Eccube\Entity\Master\Pref $pref = null ) : Order
$pref Eccube\Entity\Master\Pref
Результат Order
    public function setPref(\Eccube\Entity\Master\Pref $pref = null)
    {
        $this->Pref = $pref;
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Order オブジェクトを生成して返す.
  *
  * @param \Eccube\Entity\Customer $Customer Customer インスタンス
  * @param array $ProductClasses 明細行となる ProductClass の配列
  * @return \Eccube\Entity\Order
  */
 public function createOrder(Customer $Customer, array $ProductClasses = array())
 {
     $faker = $this->getFaker();
     $quantity = $faker->randomNumber(2);
     $Pref = $this->app['eccube.repository.master.pref']->find(1);
     $Order = new Order($this->app['eccube.repository.order_status']->find($this->app['config']['order_processing']));
     $Order->setCustomer($Customer);
     $Order->copyProperties($Customer);
     $Order->setPref($Pref);
     $this->app['orm.em']->persist($Order);
     $this->app['orm.em']->flush($Order);
     $Delivery = $this->app['eccube.repository.delivery']->find(1);
     $Shipping = new Shipping();
     $Shipping->copyProperties($Customer);
     $Shipping->setPref($Pref)->setDelivery($Delivery);
     $Order->addShipping($Shipping);
     $Shipping->setOrder($Order);
     $this->app['orm.em']->persist($Shipping);
     $this->app['orm.em']->flush($Shipping);
     if (empty($ProductClassess)) {
         $Product = $this->createProduct();
         $ProductClasses = $Product->getProductClasses();
     }
     $subTotal = 0;
     foreach ($ProductClasses as $ProductClass) {
         $Product = $ProductClass->getProduct();
         $OrderDetail = new OrderDetail();
         $TaxRule = $this->app['eccube.repository.tax_rule']->getByRule();
         // デフォルト課税規則
         $OrderDetail->setProduct($Product)->setProductClass($ProductClass)->setProductName($Product->getName())->setProductCode($ProductClass->getCode())->setPrice($ProductClass->getPrice02())->setQuantity($quantity)->setTaxRule($TaxRule->getCalcRule()->getId())->setTaxRate($TaxRule->getTaxRate());
         $this->app['orm.em']->persist($OrderDetail);
         $OrderDetail->setOrder($Order);
         $this->app['orm.em']->flush($OrderDetail);
         $Order->addOrderDetail($OrderDetail);
         $ShipmentItem = new ShipmentItem();
         $ShipmentItem->setShipping($Shipping)->setOrder($Order)->setProductClass($ProductClass)->setProduct($Product)->setProductName($Product->getName())->setProductCode($ProductClass->getCode())->setPrice($ProductClass->getPrice02())->setQuantity($quantity);
         $Shipping->addShipmentItem($ShipmentItem);
         $this->app['orm.em']->persist($ShipmentItem);
         $this->app['orm.em']->flush($ShipmentItem);
         $subTotal += $OrderDetail->getPriceIncTax() * $OrderDetail->getQuantity();
     }
     // TODO 送料, 手数料の加算
     $Order->setSubTotal($subTotal);
     $Order->setTotal($subTotal);
     $Order->setPaymentTotal($subTotal);
     $this->app['orm.em']->flush($Order);
     return $Order;
 }
All Usage Examples Of Eccube\Entity\Order::setPref