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


PHP QuoteRepository::get方法代码示例

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


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

示例1: savePaymentInQuote

 /**
  * Saves payment information in quote
  *
  * @param Object $response
  * @return void
  */
 public function savePaymentInQuote($response)
 {
     $quote = $this->quoteRepository->get($this->sessionTransparent->getQuoteId());
     /** @var InfoInterface $payment */
     $payment = $this->paymentManagement->get($quote->getId());
     $payment->setAdditionalInformation('pnref', $response->getPnref());
     $this->errorHandler->handle($payment, $response);
     $this->paymentManagement->set($quote->getId(), $payment);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:Transaction.php

示例2: execute

 /**
  * Return shipping options items for shipping address from request
  *
  * @return void
  */
 public function execute()
 {
     try {
         $quoteId = $this->getRequest()->getParam('quote_id');
         $this->_quote = $this->quoteRepository->get($quoteId);
         $this->_initCheckout();
         $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams());
         $this->getResponse()->setBody($response);
     } catch (\Exception $e) {
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:17,代码来源:ShippingOptionsCallback.php

示例3: get

 /**
  * Get active quote by id
  *
  * @param int $cartId
  * @param int[] $sharedStoreIds
  * @throws NoSuchEntityException
  * @return CartInterface
  */
 public function get($cartId, array $sharedStoreIds = [])
 {
     $quote = parent::get($cartId, $sharedStoreIds);
     if (!$quote->getIsActive()) {
         throw NoSuchEntityException::singleField('cartId', $cartId);
     }
     return $quote;
 }
开发者ID:luo3555,项目名称:magento2-samples,代码行数:16,代码来源:QuoteRepository.php

示例4: get

 /**
  * {@inheritdoc}
  */
 public function get($cartId, array $sharedStoreIds = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'get');
     if (!$pluginInfo) {
         return parent::get($cartId, $sharedStoreIds);
     } else {
         return $this->___callPlugins('get', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php

示例5: testGetWithSharedStoreIds

 public function testGetWithSharedStoreIds()
 {
     $cartId = 16;
     $sharedStoreIds = [1, 2];
     $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock);
     $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock);
     $this->quoteMock->expects($this->once())->method('setSharedStoreIds')->with($sharedStoreIds)->willReturnSelf();
     $this->quoteMock->expects($this->once())->method('load')->with($cartId)->willReturn($this->storeMock);
     $this->quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
     $this->assertEquals($this->quoteMock, $this->model->get($cartId, $sharedStoreIds));
     $this->assertEquals($this->quoteMock, $this->model->get($cartId, $sharedStoreIds));
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:13,代码来源:QuoteRepositoryTest.php

示例6: getQuoteData

 /**
  * Retrieve quote data
  *
  * @return array
  */
 private function getQuoteData()
 {
     $quoteData = [];
     if ($this->checkoutSession->getQuote()->getId()) {
         $quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
         $quoteData = $quote->toArray();
         $quoteData['is_virtual'] = $quote->getIsVirtual();
         if (!$quote->getCustomer()->getId()) {
             /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
             $quoteIdMask = $this->quoteIdMaskFactory->create();
             $quoteData['entity_id'] = $quoteIdMask->load($this->checkoutSession->getQuote()->getId(), 'quote_id')->getMaskedId();
         }
     }
     return $quoteData;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:20,代码来源:DefaultConfigProvider.php

示例7: restoreQuote

 /**
  * Restore last active quote
  *
  * @return bool True if quote restored successfully, false otherwise
  */
 public function restoreQuote()
 {
     /** @var \Magento\Sales\Model\Order $order */
     $order = $this->getLastRealOrder();
     if ($order->getId()) {
         try {
             $quote = $this->quoteRepository->get($order->getQuoteId());
             $quote->setIsActive(1)->setReservedOrderId(null);
             $this->quoteRepository->save($quote);
             $this->replaceQuote($quote)->unsLastRealOrderId();
             $this->_eventManager->dispatch('restore_quote', ['order' => $order, 'quote' => $quote]);
             return true;
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         }
     }
     return false;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:22,代码来源:Session.php

示例8: _processOrder

 /**
  * Operate with order using information from silent post
  *
  * @param \Magento\Sales\Model\Order $order
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _processOrder(\Magento\Sales\Model\Order $order)
 {
     $response = $this->getResponse();
     $payment = $order->getPayment();
     $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0);
     $canSendNewOrderEmail = true;
     if ($response->getResult() == self::RESPONSE_CODE_FRAUDSERVICE_FILTER || $response->getResult() == self::RESPONSE_CODE_DECLINED_BY_FILTER) {
         $canSendNewOrderEmail = false;
         $payment->setIsTransactionPending(true)->setIsFraudDetected(true);
         $fraudMessage = $response->getData('respmsg');
         if ($response->getData('fps_prexmldata')) {
             $xml = new \SimpleXMLElement($response->getData('fps_prexmldata'));
             $fraudMessage = (string) $xml->rule->triggeredMessage;
         }
         $payment->setAdditionalInformation(Info::PAYPAL_FRAUD_FILTERS, $fraudMessage);
     }
     if ($response->getData('avsdata') && strstr(substr($response->getData('avsdata'), 0, 2), 'N')) {
         $payment->setAdditionalInformation(Info::PAYPAL_AVS_CODE, substr($response->getData('avsdata'), 0, 2));
     }
     if ($response->getData('cvv2match') && $response->getData('cvv2match') != 'Y') {
         $payment->setAdditionalInformation(Info::PAYPAL_CVV_2_MATCH, $response->getData('cvv2match'));
     }
     switch ($response->getType()) {
         case self::TRXTYPE_AUTH_ONLY:
             $payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized());
             break;
         case self::TRXTYPE_SALE:
             $payment->registerCaptureNotification($payment->getBaseAmountAuthorized());
             break;
         default:
             break;
     }
     $order->save();
     try {
         if ($canSendNewOrderEmail) {
             $this->orderSender->send($order);
         }
         $quote = $this->quoteRepository->get($order->getQuoteId())->setIsActive(false);
         $this->quoteRepository->save($quote);
     } catch (\Exception $e) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We cannot send the new order email.'));
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:52,代码来源:Payflowlink.php

示例9: getQuoteData

 /**
  * Retrieve quote data
  *
  * @return array
  */
 private function getQuoteData()
 {
     $quoteData = [];
     if ($this->checkoutSession->getQuote()->getId()) {
         $quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
         // the following condition is a legacy logic left here for compatibility
         if (!$quote->getCustomer()->getId()) {
             $this->quoteRepository->save($this->checkoutSession->getQuote()->setCheckoutMethod('guest'));
         } else {
             $this->quoteRepository->save($this->checkoutSession->getQuote()->setCheckoutMethod(null));
         }
         $quoteData = $quote->toArray();
         $quoteData['is_virtual'] = $quote->getIsVirtual();
         if (!$quote->getCustomer()->getId()) {
             /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
             $quoteIdMask = $this->quoteIdMaskFactory->create();
             $quoteData['entity_id'] = $quoteIdMask->load($this->checkoutSession->getQuote()->getId(), 'quote_id')->getMaskedId();
         }
     }
     return $quoteData;
 }
开发者ID:kid17,项目名称:magento2,代码行数:26,代码来源:DefaultConfigProvider.php

示例10: processOrder

 /**
  * Operate with order using information from Authorize.net.
  * Authorize order or authorize and capture it.
  *
  * @param \Magento\Sales\Model\Order $order
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  * @throws \Exception
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function processOrder(\Magento\Sales\Model\Order $order)
 {
     try {
         $this->checkResponseCode();
         $this->checkTransId();
     } catch (\Exception $e) {
         //decline the order (in case of wrong response code) but don't return money to customer.
         $message = $e->getMessage();
         $this->declineOrder($order, $message, false);
         throw $e;
     }
     $response = $this->getResponse();
     //create transaction. need for void if amount will not match.
     $payment = $order->getPayment();
     $this->fillPaymentByResponse($payment);
     $payment->getMethodInstance()->setIsInitializeNeeded(false);
     $payment->getMethodInstance()->setResponseData($response->getData());
     $this->processPaymentFraudStatus($payment);
     $payment->place();
     $this->addStatusComment($payment);
     $order->save();
     //match amounts. should be equals for authorization.
     //decline the order if amount does not match.
     if (!$this->matchAmount($payment->getBaseAmountAuthorized())) {
         $message = __('Something went wrong: the paid amount doesn\'t match the order amount.' . ' Please correct this and try again.');
         $this->declineOrder($order, $message, true);
         throw new \Magento\Framework\Exception\LocalizedException($message);
     }
     try {
         if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) {
             $this->orderSender->send($order);
         }
         $quote = $this->quoteRepository->get($order->getQuoteId())->setIsActive(false);
         $this->quoteRepository->save($quote);
     } catch (\Exception $e) {
         // do not cancel order if we couldn't send email
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:48,代码来源:Directpost.php

示例11: getQuote

 /**
  * Retrieve quote model object
  *
  * @return \Magento\Quote\Model\Quote
  */
 public function getQuote()
 {
     if ($this->_quote === null) {
         $this->_quote = $this->quoteRepository->create();
         if ($this->getStoreId()) {
             if (!$this->getQuoteId()) {
                 $this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId())->setIsActive(false)->setStoreId($this->getStoreId());
                 $this->quoteRepository->save($this->_quote);
                 $this->setQuoteId($this->_quote->getId());
             } else {
                 $this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
                 $this->_quote->setStoreId($this->getStoreId());
             }
             if ($this->getCustomerId()) {
                 $customer = $this->customerRepository->getById($this->getCustomerId());
                 $this->_quote->assignCustomer($customer);
             }
         }
         $this->_quote->setIgnoreOldQty(true);
         $this->_quote->setIsSuperMode(true);
     }
     return $this->_quote;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:Quote.php

示例12: getConfig

 /**
  * @return ConfigInterface
  */
 protected function getConfig()
 {
     $quote = $this->quoteRepository->get($this->sessionTransparent->getQuoteId());
     return $this->paymentManagement->get($quote->getId())->getMethodInstance()->getConfigInterface();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:8,代码来源:AbstractFilterValidator.php


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