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


PHP CartRepositoryInterface::get方法代码示例

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


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

示例1: placeOrder

 /**
  * {@inheritdoc}
  */
 public function placeOrder($cartId, $agreements = null, PaymentInterface $paymentMethod = null)
 {
     /** @var $quoteIdMask QuoteIdMask */
     $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
     $this->cartRepository->get($quoteIdMask->getQuoteId())->setCheckoutMethod(CartManagementInterface::METHOD_GUEST);
     return $this->quoteManagement->placeOrder($quoteIdMask->getQuoteId(), $agreements, $paymentMethod);
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:GuestCartManagement.php

示例2: 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:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:Transaction.php

示例3: 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:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:ShippingOptionsCallback.php

示例4: calculate

 /**
  * {@inheritDoc}
  */
 public function calculate($cartId, \Magento\Checkout\Api\Data\TotalsInformationInterface $addressInformation)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->cartRepository->get($cartId);
     $this->validateQuote($quote);
     if ($quote->getIsVirtual()) {
         $quote->setBillingAddress($addressInformation->getAddress());
     } else {
         $quote->setShippingAddress($addressInformation->getAddress());
         $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod($addressInformation->getShippingCarrierCode() . '_' . $addressInformation->getShippingMethodCode());
     }
     $quote->collectTotals();
     return $this->cartTotalRepository->get($cartId);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:TotalsInformationManagement.php

示例5: recordOrder

 protected function recordOrder($order)
 {
     $customOrderId = null;
     //https://github.com/magento/magento2/issues/4233
     $quoteId = $order->getQuoteId();
     $quote = $this->quoteRepository->get($quoteId);
     $shippingAddress = $quote->getShippingAddress();
     $carrierType = $shippingAddress->getCarrierType();
     //  $order->setCarrierType($carrierType);
     $order->setDestinationType($shippingAddress->getDestinationType());
     $order->setValidationStatus($shippingAddress->getValidationStatus());
     $this->carrierGroupHelper->saveOrderDetail($order, $shippingAddress);
     $this->carrierGroupHelper->recordOrderItems($order);
     $this->packageHelper->saveOrderPackages($order, $shippingAddress);
     if (strstr($order->getShippingMethod(), 'shqshared_')) {
         $orderDetailArray = $this->carrierGroupHelper->loadOrderDetailByOrderId($order->getId());
         //SHQ16- Review for splits
         foreach ($orderDetailArray as $orderDetail) {
             $original = $orderDetail->getCarrierType();
             $carrierTypeArray = explode('_', $orderDetail->getCarrierType());
             if (is_array($carrierTypeArray)) {
                 $orderDetail->setCarrierType($carrierTypeArray[1]);
                 //SHQ16-1026
                 $currentShipDescription = $order->getShippingDescription();
                 $shipDescriptionArray = explode('-', $currentShipDescription);
                 $cgArray = $this->shipperDataHelper->decodeShippingDetails($orderDetail->getCarrierGroupDetail());
                 foreach ($cgArray as $key => $cgDetail) {
                     if (isset($cgDetail['carrierType']) && $cgDetail['carrierType'] == $original) {
                         $cgDetail['carrierType'] = $carrierTypeArray[1];
                     }
                     if (is_array($shipDescriptionArray) && isset($cgDetail['carrierTitle'])) {
                         $shipDescriptionArray[0] = $cgDetail['carrierTitle'] . ' ';
                         $newShipDescription = implode('-', $shipDescriptionArray);
                         $order->setShippingDescription($newShipDescription);
                     }
                     $cgArray[$key] = $cgDetail;
                 }
                 $encoded = $this->shipperDataHelper->encode($cgArray);
                 $orderDetail->setCarrierGroupDetail($encoded);
                 $orderDetail->save();
             }
             $this->shipperLogger->postInfo('Shipperhq_Shipper', 'Rates displayed as single carrier', 'Resetting carrier type on order to be ' . $carrierTypeArray[1]);
         }
     }
     if ($this->shipperDataHelper->useDefaultCarrierCodes()) {
         $order->setShippingMethod($this->getDefaultCarrierShipMethod($order, $shippingAddress));
     }
     $order->save();
 }
开发者ID:shipperhq,项目名称:module-shipper,代码行数:49,代码来源:AbstractRecordOrder.php

示例6: reOrder

 /**
  * @param $quoteId
  *
  * @return Quote
  */
 public function reOrder($quoteId)
 {
     $quote = $this->_quoteRepository->get($quoteId);
     $quote->setIsActive(1)->setReservedOrderId(null);
     $this->_quoteRepository->save($quote);
     return $quote;
 }
开发者ID:wirecard,项目名称:magento2-wcp,代码行数:12,代码来源:OrderManagement.php

示例7: getQuote

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

示例8: 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(1);
     $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:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:QuoteRepositoryTest.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());
         $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:nblair,项目名称:magescotch,代码行数:20,代码来源:DefaultConfigProvider.php

示例10: 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:pradeep-wagento,项目名称:magento2,代码行数:22,代码来源:Session.php

示例11: _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:Doability,项目名称:magento2dev,代码行数:52,代码来源:Payflowlink.php

示例12: 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:kidaa30,项目名称:magento2-platformsh,代码行数:48,代码来源:Directpost.php

示例13: getList

 /**
  * {@inheritdoc}
  */
 public function getList($cartId)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->quoteRepository->get($cartId);
     return $this->methodList->getAvailableMethods($quote);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:9,代码来源:PaymentMethodManagement.php

示例14: getConfig

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

示例15: get

 /**
  * {@inheritdoc}
  */
 public function get($cartId)
 {
     /** @var $quoteIdMask QuoteIdMask */
     $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
     return $this->quoteRepository->get($quoteIdMask->getQuoteId());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:GuestCartRepository.php


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