Get Shippings
public getShippings ( ) : Doctrine\Common\Collections\Collection | ||
Résultat | Doctrine\Common\Collections\Collection |
/** * 受注再編集用フォーム作成. * * @param Order $Order * @return array */ public function createFormDataForEdit(Order $Order) { //受注アイテム $orderDetail = array(); $OrderDetailColl = $Order->getOrderDetails(); foreach ($OrderDetailColl as $OrderDetail) { $orderDetail[] = array('Product' => $OrderDetail->getProduct()->getId(), 'ProductClass' => $OrderDetail->getProductClass()->getId(), 'price' => $OrderDetail->getPrice(), 'quantity' => $OrderDetail->getQuantity(), 'tax_rate' => $OrderDetail->getTaxRate(), 'tax_rule' => $OrderDetail->getTaxRule()); } //受注お届け $shippings = array(); $ShippingsColl = $Order->getShippings(); foreach ($ShippingsColl as $Shippings) { $deliveryTime = ''; if (is_object($Shippings->getDeliveryTime())) { $deliveryTime = $Shippings->getDeliveryTime()->getId(); } $shippingDeliveryDate = array('year' => null, 'month' => null, 'day' => null); if ($Shippings->getShippingDeliveryDate() instanceof \DateTime) { $shippingDeliveryDate['year'] = $Shippings->getShippingDeliveryDate()->format('Y'); $shippingDeliveryDate['month'] = $Shippings->getShippingDeliveryDate()->format('m'); $shippingDeliveryDate['day'] = $Shippings->getShippingDeliveryDate()->format('d'); } $shippings[] = array('name' => array('name01' => $Shippings->getName01(), 'name02' => $Shippings->getName02()), 'kana' => array('kana01' => $Shippings->getKana01(), 'kana02' => $Shippings->getKana02()), 'company_name' => $Shippings->getCompanyName(), 'zip' => array('zip01' => $Shippings->getZip01(), 'zip02' => $Shippings->getZip02()), 'address' => array('pref' => $Shippings->getPref()->getId(), 'addr01' => $Shippings->getAddr01(), 'addr02' => $Shippings->getAddr02()), 'tel' => array('tel01' => $Shippings->getTel01(), 'tel02' => $Shippings->getTel02(), 'tel03' => $Shippings->getTel03()), 'fax' => array('fax01' => $Shippings->getFax01(), 'fax02' => $Shippings->getFax02(), 'fax03' => $Shippings->getFax03()), 'Delivery' => $Shippings->getDelivery()->getId(), 'DeliveryTime' => $deliveryTime, 'shipping_delivery_date' => $shippingDeliveryDate); } $Customer = $Order->getCustomer(); $customer_id = null; if (is_object($Customer)) { $customer_id = $Customer->getId(); } //受注フォーム $order = array('_token' => 'dummy', 'OrderStatus' => (string) $Order->getOrderStatus(), 'Customer' => (string) $customer_id, 'name' => array('name01' => $Order->getName01(), 'name02' => $Order->getName02()), 'kana' => array('kana01' => $Order->getKana01(), 'kana02' => $Order->getKana02()), 'zip' => array('zip01' => $Order->getZip01(), 'zip02' => $Order->getZip02()), 'address' => array('pref' => $Order->getPref()->getId(), 'addr01' => $Order->getAddr01(), 'addr02' => $Order->getAddr02()), 'email' => $Order->getEmail(), 'tel' => array('tel01' => $Order->getTel01(), 'tel02' => $Order->getTel02(), 'tel03' => $Order->getTel03()), 'fax' => array('fax01' => $Order->getFax01(), 'fax02' => $Order->getFax02(), 'fax03' => $Order->getFax03()), 'company_name' => $Order->getCompanyName(), 'message' => $Order->getMessage(), 'OrderDetails' => $orderDetail, 'discount' => $Order->getDiscount(), 'delivery_fee_total' => $Order->getDeliveryFeeTotal(), 'charge' => $Order->getCharge(), 'Payment' => $Order->getPayment()->getId(), 'Shippings' => $shippings, 'note' => $Order->getNote()); return $order; }
/** * 配送料無料条件(合計金額)の条件を満たしていれば配送料金を0に設定 * * @param Order $Order */ public function setDeliveryFreeAmount(Order $Order) { // 配送料無料条件(合計金額) $deliveryFreeAmount = $this->BaseInfo->getDeliveryFreeAmount(); if (!is_null($deliveryFreeAmount)) { // 合計金額が設定金額以上であれば送料無料 if ($Order->getSubTotal() >= $deliveryFreeAmount) { $Order->setDeliveryFeeTotal(0); // お届け先情報の配送料も0にセット $shippings = $Order->getShippings(); foreach ($shippings as $Shipping) { $Shipping->setShippingDeliveryFee(0); } } } }
/** * フォームからの入直内容に基づいて、受注情報の再計算を行う * * @param $app * @param $Order */ protected function calculate($app, \Eccube\Entity\Order $Order) { $taxtotal = 0; $subtotal = 0; // 受注明細データの税・小計を再計算 /** @var $OrderDetails \Eccube\Entity\OrderDetail[] */ $OrderDetails = $Order->getOrderDetails(); foreach ($OrderDetails as $OrderDetail) { // 新規登録の場合は, 入力されたproduct_id/produc_class_idから明細にセットする. if (!$OrderDetail->getId()) { $TaxRule = $app['eccube.repository.tax_rule']->getByRule($OrderDetail->getProduct(), $OrderDetail->getProductClass()); $OrderDetail->setTaxRule($TaxRule->getCalcRule()->getId()); $OrderDetail->setProductName($OrderDetail->getProduct()->getName()); $OrderDetail->setProductCode($OrderDetail->getProductClass()->getCode()); $OrderDetail->setClassName1($OrderDetail->getProductClass()->hasClassCategory1() ? $OrderDetail->getProductClass()->getClassCategory1()->getClassName()->getName() : null); $OrderDetail->setClassName2($OrderDetail->getProductClass()->hasClassCategory2() ? $OrderDetail->getProductClass()->getClassCategory2()->getClassName()->getName() : null); $OrderDetail->setClassCategoryName1($OrderDetail->getProductClass()->hasClassCategory1() ? $OrderDetail->getProductClass()->getClassCategory1()->getName() : null); $OrderDetail->setClassCategoryName2($OrderDetail->getProductClass()->hasClassCategory2() ? $OrderDetail->getProductClass()->getClassCategory2()->getName() : null); } // 税 $tax = $app['eccube.service.tax_rule']->calcTax($OrderDetail->getPrice(), $OrderDetail->getTaxRate(), $OrderDetail->getTaxRule()); $OrderDetail->setPriceIncTax($OrderDetail->getPrice() + $tax); $taxtotal += $tax; // 小計 $subtotal += $OrderDetail->getTotalPrice(); } $shippings = $Order->getShippings(); /** @var \Eccube\Entity\Shipping $Shipping */ foreach ($shippings as $Shipping) { $shipmentItems = $Shipping->getShipmentItems(); $Shipping->setDelFlg(Constant::DISABLED); /** @var \Eccube\Entity\ShipmentItem $ShipmentItem */ if (!$Shipping->getId()) { foreach ($shipmentItems as $ShipmentItem) { $ShipmentItem->setProductName($ShipmentItem->getProduct()->getName()); $ShipmentItem->setProductCode($ShipmentItem->getProductClass()->getCode()); $ShipmentItem->setClassName1($ShipmentItem->getProductClass()->hasClassCategory1() ? $ShipmentItem->getProductClass()->getClassCategory1()->getClassName()->getName() : null); $ShipmentItem->setClassName2($ShipmentItem->getProductClass()->hasClassCategory2() ? $ShipmentItem->getProductClass()->getClassCategory2()->getClassName()->getName() : null); $ShipmentItem->setClassCategoryName1($ShipmentItem->getProductClass()->hasClassCategory1() ? $ShipmentItem->getProductClass()->getClassCategory1()->getName() : null); $ShipmentItem->setClassCategoryName2($ShipmentItem->getProductClass()->hasClassCategory2() ? $ShipmentItem->getProductClass()->getClassCategory2()->getName() : null); } } } // 受注データの税・小計・合計を再計算 $Order->setTax($taxtotal); $Order->setSubtotal($subtotal); $Order->setTotal($subtotal + $Order->getCharge() + $Order->getDeliveryFeeTotal() - $Order->getDiscount()); // お支払い合計は、totalと同一金額(2系ではtotal - point) $Order->setPaymentTotal($Order->getTotal()); }
/** * 受注情報、お届け先情報の更新 * * @param $em トランザクション制御されているEntityManager * @param $Order 受注情報 * @param $formData フォームデータ */ public function setOrderUpdate($em, \Eccube\Entity\Order $Order, $formData) { // 受注情報を更新 $Order->setOrderDate(new \DateTime()); $Order->setOrderStatus($this->app['eccube.repository.order_status']->find($this->app['config']['order_new'])); $Order->setMessage($formData['message']); // お届け先情報を更新 $shippings = $Order->getShippings(); foreach ($shippings as $shipping) { $shipping->setShippingDeliveryName($formData['delivery']->getName()); if (!empty($formData['deliveryTime'])) { $shipping->setShippingDeliveryTime($formData['deliveryTime']->getDeliveryTime()); } if (!empty($formData['deliveryDate'])) { $shipping->setShippingDeliveryDate(new \DateTime($formData['deliveryDate'])); } $shipping->setShippingDeliveryFee($shipping->getDeliveryFee()->getFee()); } }
/** * 配送料の合計金額を計算 * * @param Order $Order * @return Order */ public function calculateDeliveryFee(Order $Order) { // 配送業者を取得 $shippings = $Order->getShippings(); // 配送料合計金額 $Order->setDeliveryFeeTotal($this->getShippingDeliveryFeeTotal($shippings)); // 配送料無料条件(合計金額) $this->setDeliveryFreeAmount($Order); // 配送料無料条件(合計数量) $this->setDeliveryFreeQuantity($Order); return $Order; }