当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::setData方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order::setData方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::setData方法的具体用法?PHP Order::setData怎么用?PHP Order::setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order的用法示例。


在下文中一共展示了Order::setData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupOrder

 private function setupOrder($orderData)
 {
     //Set up order mock
     foreach ($orderData['data_fields'] as $key => $value) {
         $this->order->setData($key, $value);
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:WeeeTest.php

示例2: _addStatusHistoryComment

 /**
  * @desc order comments or history
  * @param type $order
  */
 protected function _addStatusHistoryComment()
 {
     $success_result = strcmp($this->_success, 'true') == 0 || strcmp($this->_success, '1') == 0 ? 'true' : 'false';
     $success = !empty($this->_reason) ? "{$success_result} <br />reason:{$this->_reason}" : $success_result;
     if ($this->_eventCode == Notification::REFUND || $this->_eventCode == Notification::CAPTURE) {
         $currency = $this->_order->getOrderCurrencyCode();
         // check if it is a full or partial refund
         $amount = $this->_value;
         $orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
         $this->_debugData['_addStatusHistoryComment amount'] = 'amount notification:' . $amount . ' amount order:' . $orderAmount;
         if ($amount == $orderAmount) {
             //                $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
             $this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
         } else {
             //                $this->_order->setAdyenEventCode("(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
             $this->_order->setData('adyen_notification_event_code', "(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
         }
     } else {
         //            $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
         $this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
     }
     // if payment method is klarna or openinvoice/afterpay show the reservartion number
     if (($this->_paymentMethod == "klarna" || $this->_paymentMethod == "afterpay_default" || $this->_paymentMethod == "openinvoice") && ($this->_klarnaReservationNumber != null && $this->_klarnaReservationNumber != "")) {
         $klarnaReservationNumberText = "<br /> reservationNumber: " . $this->_klarnaReservationNumber;
     } else {
         $klarnaReservationNumberText = "";
     }
     if ($this->_boletoPaidAmount != null && $this->_boletoPaidAmount != "") {
         $boletoPaidAmountText = "<br /> Paid amount: " . $this->_boletoPaidAmount;
     } else {
         $boletoPaidAmountText = "";
     }
     $type = 'Adyen HTTP Notification(s):';
     $comment = __('%1 <br /> eventCode: %2 <br /> pspReference: %3 <br /> paymentMethod: %4 <br /> success: %5 %6 %7', $type, $this->_eventCode, $this->_pspReference, $this->_paymentMethod, $success, $klarnaReservationNumberText, $boletoPaidAmountText);
     // If notification is pending status and pending status is set add the status change to the comment history
     if ($this->_eventCode == Notification::PENDING) {
         $pendingStatus = $this->_getConfigData('pending_status', 'adyen_abstract', $this->_order->getStoreId());
         if ($pendingStatus != "") {
             $this->_order->addStatusHistoryComment($comment, $pendingStatus);
             $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $pendingStatus;
             return;
         }
     }
     // if manual review is accepted and a status is selected. Change the status through this comment history item
     if ($this->_eventCode == Notification::MANUAL_REVIEW_ACCEPT && $this->_getFraudManualReviewAcceptStatus() != "") {
         $manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus();
         $this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
         $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus;
         return;
     }
     $this->_order->addStatusHistoryComment($comment);
     $this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification';
 }
开发者ID:pivulic,项目名称:adyen-magento2,代码行数:57,代码来源:Cron.php

示例3: testCollect

 /**
  * @param array $orderData
  * @param array $creditmemoData
  * @param array $expectedResults
  * @dataProvider collectDataProvider
  */
 public function testCollect($orderData, $creditmemoData, $expectedResults)
 {
     $roundingDelta = [];
     //Set up order mock
     foreach ($orderData['data_fields'] as $key => $value) {
         $this->order->setData($key, $value);
     }
     //Set up creditmemo mock
     /** @var \Magento\Sales\Model\Order\Creditmemo\Item[] $creditmemoItems */
     $creditmemoItems = [];
     foreach ($creditmemoData['items'] as $itemKey => $creditmemoItemData) {
         $creditmemoItems[$itemKey] = $this->getCreditmemoItem($creditmemoItemData);
     }
     $this->creditmemo->expects($this->once())->method('getAllItems')->will($this->returnValue($creditmemoItems));
     $this->creditmemo->expects($this->any())->method('isLast')->will($this->returnValue($creditmemoData['is_last']));
     foreach ($creditmemoData['data_fields'] as $key => $value) {
         $this->creditmemo->setData($key, $value);
     }
     $this->creditmemo->expects($this->any())->method('roundPrice')->will($this->returnCallback(function ($price, $type) use(&$roundingDelta) {
         if (!isset($roundingDelta[$type])) {
             $roundingDelta[$type] = 0;
         }
         $roundedPrice = round($price + $roundingDelta[$type], 2);
         $roundingDelta[$type] = $price - $roundedPrice;
         return $roundedPrice;
     }));
     $this->model->collect($this->creditmemo);
     //verify invoice data
     foreach ($expectedResults['creditmemo_data'] as $key => $value) {
         $this->assertEquals($value, $this->creditmemo->getData($key));
     }
     //verify invoice item data
     foreach ($expectedResults['creditmemo_items'] as $itemKey => $itemData) {
         $creditmemoItem = $creditmemoItems[$itemKey];
         foreach ($itemData as $key => $value) {
             $this->assertEquals($value, $creditmemoItem->getData($key));
         }
     }
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:45,代码来源:TaxTest.php

示例4: _prepareOrderPayment

 /**
  * Prepare payment for the order
  *
  * @param \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject $order
  * @param array $mockedMethods
  * @return \Magento\Sales\Model\Order\Payment|\PHPUnit_Framework_MockObject_MockObject
  */
 protected function _prepareOrderPayment($order, $mockedMethods = [])
 {
     $payment = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
     foreach ($mockedMethods as $method => $value) {
         $payment->expects($this->any())->method($method)->will($this->returnValue($value));
     }
     $payment->expects($this->any())->method('isDeleted')->will($this->returnValue(false));
     $order->setData(\Magento\Sales\Api\Data\OrderInterface::PAYMENTS, [$payment]);
     return $payment;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:17,代码来源:OrderTest.php


注:本文中的Magento\Sales\Model\Order::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。