• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Api\CartRepositoryInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute

 /**
  * Initialize coupon
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function execute()
 {
     $couponCode = $this->getRequest()->getParam('remove') == 1 ? '' : trim($this->getRequest()->getParam('coupon_code'));
     $cartQuote = $this->cart->getQuote();
     $oldCouponCode = $cartQuote->getCouponCode();
     $codeLength = strlen($couponCode);
     if (!$codeLength && !strlen($oldCouponCode)) {
         return $this->_goBack();
     }
     try {
         $isCodeLengthValid = $codeLength && $codeLength <= \Magento\Checkout\Helper\Cart::COUPON_CODE_MAX_LENGTH;
         $itemsCount = $cartQuote->getItemsCount();
         if ($itemsCount) {
             $cartQuote->getShippingAddress()->setCollectShippingRates(true);
             $cartQuote->setCouponCode($isCodeLengthValid ? $couponCode : '')->collectTotals();
             $this->quoteRepository->save($cartQuote);
         }
         if ($codeLength) {
             $escaper = $this->_objectManager->get('Magento\\Framework\\Escaper');
             if (!$itemsCount) {
                 if ($isCodeLengthValid) {
                     $coupon = $this->couponFactory->create();
                     $coupon->load($couponCode, 'code');
                     if ($coupon->getId()) {
                         $this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save();
                         $this->messageManager->addSuccess(__('You used coupon code "%1".', $escaper->escapeHtml($couponCode)));
                     } else {
                         $this->messageManager->addError(__('The coupon code "%1" is not valid.', $escaper->escapeHtml($couponCode)));
                     }
                 } else {
                     $this->messageManager->addError(__('The coupon code "%1" is not valid.', $escaper->escapeHtml($couponCode)));
                 }
             } else {
                 if ($isCodeLengthValid && $couponCode == $cartQuote->getCouponCode()) {
                     $this->messageManager->addSuccess(__('You used coupon code "%1".', $escaper->escapeHtml($couponCode)));
                 } else {
                     $this->messageManager->addError(__('The coupon code "%1" is not valid.', $escaper->escapeHtml($couponCode)));
                     $this->cart->save();
                 }
             }
         } else {
             $this->messageManager->addSuccess(__('You canceled the coupon code.'));
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->messageManager->addError(__('We cannot apply the coupon code.'));
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
     }
     return $this->_goBack();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:58,代码来源:CouponPost.php


示例2: get

 /**
  * {@inheritDoc}
  *
  * @param int $cartId The cart ID.
  * @return Totals Quote totals data.
  */
 public function get($cartId)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->quoteRepository->getActive($cartId);
     if ($quote->isVirtual()) {
         $addressTotalsData = $quote->getBillingAddress()->getData();
         $addressTotals = $quote->getBillingAddress()->getTotals();
     } else {
         $addressTotalsData = $quote->getShippingAddress()->getData();
         $addressTotals = $quote->getShippingAddress()->getTotals();
     }
     /** @var \Magento\Quote\Api\Data\TotalsInterface $quoteTotals */
     $quoteTotals = $this->totalsFactory->create();
     $this->dataObjectHelper->populateWithArray($quoteTotals, $addressTotalsData, '\\Magento\\Quote\\Api\\Data\\TotalsInterface');
     $items = [];
     foreach ($quote->getAllVisibleItems() as $index => $item) {
         $items[$index] = $this->itemConverter->modelToDataObject($item);
     }
     $calculatedTotals = $this->totalsConverter->process($addressTotals);
     $quoteTotals->setTotalSegments($calculatedTotals);
     $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
     $amount = $amount > 0 ? $amount : 0;
     $quoteTotals->setCouponCode($this->couponService->get($cartId));
     $quoteTotals->setGrandTotal($amount);
     $quoteTotals->setItems($items);
     $quoteTotals->setItemsQty($quote->getItemsQty());
     $quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
     $quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
     return $quoteTotals;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:CartTotalRepository.php


示例3: 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


示例4: updateQuote

 /**
  * Update quote data
  *
  * @param Quote $quote
  * @param array $details
  * @return void
  */
 private function updateQuote(Quote $quote, array $details)
 {
     $quote->setMayEditShippingAddress(false);
     $quote->setMayEditShippingMethod(true);
     $this->updateQuoteAddress($quote, $details);
     $this->disabledQuoteAddressValidation($quote);
     $quote->collectTotals();
     $this->quoteRepository->save($quote);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:QuoteUpdater.php


示例5: 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


示例6: execute

 /**
  * Fetch coupon info
  *
  * Controller Action
  */
 public function execute()
 {
     $total = $this->getRequest()->getParam('cost');
     $quote = $this->_checkoutSession->getQuote();
     //save value to DiscountCoupon collect
     $this->_registry->register('mercadopago_total_amount', $total);
     $this->quoteRepository->save($quote->collectTotals());
     return;
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:14,代码来源:Subtotals.php


示例7: execute

 /**
  * Initialize shipping information
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     $country = (string) $this->getRequest()->getParam('country_id');
     $postcode = (string) $this->getRequest()->getParam('estimate_postcode');
     $city = (string) $this->getRequest()->getParam('estimate_city');
     $regionId = (string) $this->getRequest()->getParam('region_id');
     $region = (string) $this->getRequest()->getParam('region');
     $this->cart->getQuote()->getShippingAddress()->setCountryId($country)->setCity($city)->setPostcode($postcode)->setRegionId($regionId)->setRegion($region)->setCollectShippingRates(true);
     $this->quoteRepository->save($this->cart->getQuote());
     $this->cart->save();
     return $this->_goBack();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:EstimatePost.php


示例8: savePaymentInformation

 /**
  * {@inheritDoc}
  */
 public function savePaymentInformation($cartId, $email, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, \Magento\Quote\Api\Data\AddressInterface $billingAddress = null)
 {
     if ($billingAddress) {
         $billingAddress->setEmail($email);
         $this->billingAddressManagement->assign($cartId, $billingAddress);
     } else {
         $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
         $this->cartRepository->getActive($quoteIdMask->getQuoteId())->getBillingAddress()->setEmail($email);
     }
     $this->paymentMethodManagement->set($cartId, $paymentMethod);
     return true;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:GuestPaymentInformationManagement.php


示例9: 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


示例10: testExecute

 public function testExecute()
 {
     $quoteMock = $this->getQuoteMock();
     $quoteMock->expects(self::exactly(2))->method('getIsVirtual')->willReturn(false);
     $quoteMock->expects(self::exactly(2))->method('getShippingAddress')->willReturn($this->shippingAddressMock);
     $this->shippingAddressMock->expects(self::once())->method('getShippingMethod')->willReturn(self::TEST_SHIPPING_METHOD . '-bad');
     $this->disabledQuoteAddressValidationStep($quoteMock);
     $this->shippingAddressMock->expects(self::once())->method('setShippingMethod')->willReturn(self::TEST_SHIPPING_METHOD);
     $this->shippingAddressMock->expects(self::once())->method('setCollectShippingRates')->willReturn(true);
     $quoteMock->expects(self::once())->method('collectTotals');
     $this->quoteRepositoryMock->expects(self::once())->method('save')->with($quoteMock);
     $this->shippingMethodUpdater->execute(self::TEST_SHIPPING_METHOD, $quoteMock);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:ShippingMethodUpdaterTest.php


示例11: 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


示例12: 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


示例13: beforeDispatch

 /**
  * @param \Magento\Checkout\Controller\Cart $subject
  * @param \Magento\Framework\App\RequestInterface $request
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(\Magento\Checkout\Controller\Cart $subject, \Magento\Framework\App\RequestInterface $request)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->checkoutSession->getQuote();
     // Clear shipping addresses and item assignments after Multishipping flow
     if ($quote->isMultipleShippingAddresses()) {
         foreach ($quote->getAllShippingAddresses() as $address) {
             $quote->removeAddress($address->getId());
         }
         $quote->getShippingAddress();
         $quote->setIsMultiShipping(false);
         $quote->collectTotals();
         $this->cartRepository->save($quote);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:CartPlugin.php


示例14: testSavePaymentInQuote

 public function testSavePaymentInQuote()
 {
     $quoteId = 1;
     $response = new DataObject();
     $payment = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
     $payment->expects($this->once())->method('setAdditionalInformation')->with('pnref');
     $this->errorHandlerMock->expects($this->once())->method('handle')->with($payment, $response);
     $quote = $this->getMock('Magento\\Quote\\Api\\Data\\CartInterface', [], [], '', false);
     $quote->expects($this->exactly(2))->method('getId')->willReturn($quoteId);
     $this->sessionTransparent->expects($this->once())->method('getQuoteId')->willReturn($quoteId);
     $this->quoteRepository->expects($this->once())->method('get')->willReturn($quote);
     $this->paymentMethodManagementInterface->expects($this->once())->method('get')->willReturn($payment);
     $this->paymentMethodManagementInterface->expects($this->once())->method('set');
     $this->model->savePaymentInQuote($response);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:TransactionTest.php


示例15: 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


示例16: saveAddressInformation

 /**
  * {@inheritDoc}
  */
 public function saveAddressInformation($cartId, \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation)
 {
     $address = $addressInformation->getShippingAddress();
     $billingAddress = $addressInformation->getBillingAddress();
     $carrierCode = $addressInformation->getShippingCarrierCode();
     $methodCode = $addressInformation->getShippingMethodCode();
     if (!$address->getCountryId()) {
         throw new StateException(__('Shipping address is not set'));
     }
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->quoteRepository->getActive($cartId);
     $quote = $this->prepareShippingAssignment($quote, $address, $carrierCode . '_' . $methodCode);
     $this->validateQuote($quote);
     $quote->setIsMultiShipping(false);
     if ($billingAddress) {
         $quote->setBillingAddress($billingAddress);
     }
     try {
         $this->quoteRepository->save($quote);
     } catch (\Exception $e) {
         $this->logger->critical($e);
         throw new InputException(__('Unable to save shipping information. Please check input data.'));
     }
     $shippingAddress = $quote->getShippingAddress();
     if (!$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) {
         throw new NoSuchEntityException(__('Carrier with such method not found: %1, %2', $carrierCode, $methodCode));
     }
     /** @var \Magento\Checkout\Api\Data\PaymentDetailsInterface $paymentDetails */
     $paymentDetails = $this->paymentDetailsFactory->create();
     $paymentDetails->setPaymentMethods($this->paymentMethodManagement->getList($cartId));
     $paymentDetails->setTotals($this->cartTotalsRepository->get($cartId));
     return $paymentDetails;
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:36,代码来源:ShippingInformationManagement.php


示例17: testGetListSuccess

 /**
  * @param int $direction
  * @param string $expectedDirection
  * @dataProvider getListSuccessDataProvider
  */
 public function testGetListSuccess($direction, $expectedDirection)
 {
     $searchResult = $this->getMock('\\Magento\\Quote\\Api\\Data\\CartSearchResultsInterface', [], [], '', false);
     $searchCriteriaMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteria', [], [], '', false);
     $cartMock = $this->getMock('Magento\\Payment\\Model\\Cart', [], [], '', false);
     $filterMock = $this->getMock('\\Magento\\Framework\\Api\\Filter', [], [], '', false);
     $pageSize = 10;
     $this->searchResultsDataFactory->expects($this->once())->method('create')->will($this->returnValue($searchResult));
     $searchResult->expects($this->once())->method('setSearchCriteria');
     $filterGroupMock = $this->getMock('\\Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false);
     $searchCriteriaMock->expects($this->any())->method('getFilterGroups')->will($this->returnValue([$filterGroupMock]));
     //addFilterGroupToCollection() checks
     $filterGroupMock->expects($this->any())->method('getFilters')->will($this->returnValue([$filterMock]));
     $filterMock->expects($this->once())->method('getField')->will($this->returnValue('store_id'));
     $filterMock->expects($this->any())->method('getConditionType')->will($this->returnValue('eq'));
     $filterMock->expects($this->once())->method('getValue')->will($this->returnValue('filter_value'));
     //back in getList()
     $this->quoteCollectionMock->expects($this->once())->method('getSize')->willReturn($pageSize);
     $searchResult->expects($this->once())->method('setTotalCount')->with($pageSize);
     $sortOrderMock = $this->getMockBuilder('Magento\\Framework\\Api\\SortOrder')->setMethods(['getField', 'getDirection'])->disableOriginalConstructor()->getMock();
     //foreach cycle
     $searchCriteriaMock->expects($this->once())->method('getSortOrders')->will($this->returnValue([$sortOrderMock]));
     $sortOrderMock->expects($this->once())->method('getField')->will($this->returnValue('id'));
     $sortOrderMock->expects($this->once())->method('getDirection')->will($this->returnValue($direction));
     $this->quoteCollectionMock->expects($this->once())->method('addOrder')->with('id', $expectedDirection);
     $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->will($this->returnValue(1));
     $searchCriteriaMock->expects($this->once())->method('getPageSize')->will($this->returnValue(10));
     $this->quoteCollectionMock->expects($this->once())->method('setCurPage')->with(1);
     $this->quoteCollectionMock->expects($this->once())->method('setPageSize')->with(10);
     $this->extensionAttributesJoinProcessorMock->expects($this->once())->method('process')->with($this->isInstanceOf('\\Magento\\Quote\\Model\\ResourceModel\\Quote\\Collection'));
     $this->quoteCollectionMock->expects($this->once())->method('getItems')->willReturn([$cartMock]);
     $searchResult->expects($this->once())->method('setItems')->with([$cartMock]);
     $this->assertEquals($searchResult, $this->model->getList($searchCriteriaMock));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:39,代码来源:QuoteRepositoryTest.php


示例18: 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


示例19: execute

 /**
  * Execute operation
  *
  * @param string $shippingMethod
  * @param Quote $quote
  * @return void
  * @throws \InvalidArgumentException
  */
 public function execute($shippingMethod, Quote $quote)
 {
     if (empty($shippingMethod)) {
         throw new \InvalidArgumentException('The "shippingMethod" field does not exists.');
     }
     if (!$quote->getIsVirtual()) {
         $shippingAddress = $quote->getShippingAddress();
         if ($shippingMethod !== $shippingAddress->getShippingMethod()) {
             $this->disabledQuoteAddressValidation($quote);
             $shippingAddress->setShippingMethod($shippingMethod);
             $shippingAddress->setCollectShippingRates(true);
             $quote->collectTotals();
             $this->quoteRepository->save($quote);
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:24,代码来源:ShippingMethodUpdater.php


示例20: testGetCartForCustomer

 public function testGetCartForCustomer()
 {
     $customerId = 100;
     $cartMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->quoteRepositoryMock->expects($this->once())->method('getActiveForCustomer')->with($customerId)->willReturn($cartMock);
     $this->assertEquals($cartMock, $this->model->getCartForCustomer($customerId));
 }
开发者ID:nblair,项目名称:magescotch,代码行数:7,代码来源:QuoteManagementTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Model\Quote类代码示例发布时间:2022-05-23
下一篇:
PHP Helper\Data类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap