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

PHP Model\Quote类代码示例

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

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



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

示例1: setUp

 protected function setUp()
 {
     $this->markTestIncomplete();
     $this->messageManager = $this->getMockForAbstractClass('Magento\\Framework\\Message\\ManagerInterface');
     $this->config = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->quote = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->quote->expects($this->any())->method('hasItems')->will($this->returnValue(true));
     $this->redirect = $this->getMockForAbstractClass('Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $this->customerData = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->checkout = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout', [], [], '', false);
     $this->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->customerSession->expects($this->any())->method('getCustomerDataObject')->will($this->returnValue($this->customerData));
     $this->checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->checkoutFactory = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout\\Factory', [], [], '', false);
     $this->checkoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->checkout));
     $this->checkoutSession->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $this->session = $this->getMock('Magento\\Framework\\Session\\Generic', [], [], '', false);
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->objectManagerCallback = function ($className) {
         if ($className == 'Magento\\Paypal\\Model\\Config') {
             return $this->config;
         }
         return $this->getMock($className, [], [], '', false);
     };
     $objectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) {
         return call_user_func($this->objectManagerCallback, $className);
     }));
     $objectManager->expects($this->any())->method('create')->will($this->returnCallback(function ($className) {
         return call_user_func($this->objectManagerCallback, $className);
     }));
     $helper = new ObjectManagerHelper($this);
     $this->model = $helper->getObject('\\Magento\\\\Paypal\\Controller\\Express\\' . $this->name, ['messageManager' => $this->messageManager, 'response' => $this->response, 'redirect' => $this->redirect, 'request' => $this->request, 'customerSession' => $this->customerSession, 'checkoutSession' => $this->checkoutSession, 'checkoutFactory' => $this->checkoutFactory, 'paypalSession' => $this->session, 'objectManager' => $objectManager]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:ExpressTest.php


示例2: populateQuoteAddress

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param array $details
  * @return $this
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function populateQuoteAddress($quote, $details)
 {
     // import shipping address
     $exportedShippingAddress = isset($details['shippingAddress']) ? $details['shippingAddress'] : null;
     if (!$quote->getIsVirtual()) {
         $shippingAddress = $quote->getShippingAddress();
         if ($exportedShippingAddress) {
             $this->importAddressData($shippingAddress, $exportedShippingAddress);
         }
         // PayPal doesn't provide detailed shipping info: prefix, suffix
         $shippingAddress->setLastname($details['lastName']);
         $shippingAddress->setFirstname($details['firstName']);
         $shippingAddress->setEmail($details['email']);
         $shippingAddress->setCollectShippingRates(true);
     }
     $exportedBillingAddress = isset($details['billingAddress']) ? $details['billingAddress'] : null;
     $billingAddress = $quote->getBillingAddress();
     if ($exportedBillingAddress) {
         $this->importBillingAddressData($billingAddress, $exportedBillingAddress);
         $billingAddress->setFirstname($details['firstName']);
         $billingAddress->setLastname($details['lastName']);
         $billingAddress->setEmail($details['email']);
     } elseif ($billingAddress->getEmail() == null) {
         $this->importAddressData($billingAddress, $exportedShippingAddress);
         $billingAddress->setFirstname($details['firstName']);
         $billingAddress->setLastname($details['lastName']);
         $billingAddress->setEmail($details['email']);
     }
     return $this;
 }
开发者ID:nja78,项目名称:magento2,代码行数:36,代码来源:Checkout.php


示例3: isFreeShipping

 /**
  * {@inheritDoc}
  */
 public function isFreeShipping(\Magento\Quote\Model\Quote $quote, $items)
 {
     /** @var \Magento\Quote\Api\Data\CartItemInterface[] $items */
     if (!count($items)) {
         return false;
     }
     $addressFreeShipping = true;
     $store = $this->storeManager->getStore($quote->getStoreId());
     $this->calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode());
     /** @var \Magento\Quote\Api\Data\CartItemInterface $item */
     foreach ($items as $item) {
         if ($item->getNoDiscount()) {
             $addressFreeShipping = false;
             $item->setFreeShipping(false);
             continue;
         }
         /** Child item discount we calculate for parent */
         if ($item->getParentItemId()) {
             continue;
         }
         $this->calculator->processFreeShipping($item);
         $itemFreeShipping = (bool) $item->getFreeShipping();
         $addressFreeShipping = $addressFreeShipping && $itemFreeShipping;
         /** Parent free shipping we apply to all children*/
         $this->applyToChildren($item, $itemFreeShipping);
     }
     return $addressFreeShipping;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:31,代码来源:FreeShipping.php


示例4: aroundAddItem

 public function aroundAddItem(\Magento\Quote\Model\Quote $subject, \Closure $proceed, \Magento\Quote\Model\Quote\Item $item)
 {
     $product = $item->getProduct();
     $attribute = $product->getResource()->getAttribute('enable_subscription');
     $value = null;
     if ($attribute) {
         $value = $attribute->getFrontend()->getValue($product);
     }
     $flag = 0;
     foreach ($subject->getAllVisibleItems() as $item) {
         $itemAttrValue = null;
         $itemProduct = $item->getProduct();
         $itemAttr = $itemProduct->getResource()->getAttribute('enable_subscription');
         if ($itemAttr) {
             if ($itemAttr->getFrontend()->getValue($itemProduct)) {
                 $flag = 1;
             }
         }
     }
     if ($value && $subject->hasItems() || $flag) {
         throw new \Magento\Framework\Exception\LocalizedException(__('Nominal item can be purchased standalone only.'));
     }
     $proceed($item);
     return $subject;
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:25,代码来源:PluginRender.php


示例5: addQuote

 /**
  * Push quote contents to given tracker
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Henhed\Piwik\Model\Tracker $tracker
  * @return \Henhed\Piwik\Helper\Tracker
  */
 public function addQuote(Quote $quote, TrackerModel $tracker)
 {
     foreach ($quote->getAllVisibleItems() as $item) {
         $this->addQuoteItem($item, $tracker);
     }
     $this->addQuoteTotal($quote, $tracker);
     return $this;
 }
开发者ID:henkelund,项目名称:magento2-henhed-piwik,代码行数:15,代码来源:Tracker.php


示例6: aroundCollect

 /**
  * If module is enabled, don't run collect totals for shipping
  *
  * Tax calculation for shipping is handled in this class
  * @see \ClassyLlama\AvaTax\Model\Tax\Sales\Total\Quote\Tax::collect()
  * Since this extension doesn't support applying discounts *after* tax, we don't need to run a separate collect
  * process.
  *
  * @param \Magento\Tax\Model\Sales\Total\Quote\Shipping $subject
  * @param \Closure $proceed
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  * @return mixed
  */
 public function aroundCollect(\Magento\Tax\Model\Sales\Total\Quote\Shipping $subject, \Closure $proceed, \Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
 {
     $storeId = $quote->getStoreId();
     // If quote is virtual, getShipping will return billing address, so no need to check if quote is virtual
     $address = $shippingAssignment->getShipping()->getAddress();
     if (!$this->config->isModuleEnabled($storeId) || $this->config->getTaxMode($storeId) == Config::TAX_MODE_NO_ESTIMATE_OR_SUBMIT || !$this->config->isAddressTaxable($address, $storeId)) {
         return $proceed($quote, $shippingAssignment, $total);
     }
 }
开发者ID:classyllama,项目名称:ClassyLlama_AvaTax,代码行数:24,代码来源:Shipping.php


示例7: isApplicable

 /**
  * Check whether payment method is applicable to quote
  *
  * @param PaymentMethodChecksInterface $paymentMethod
  * @param \Magento\Quote\Model\Quote $quote
  * @return bool
  */
 public function isApplicable(PaymentMethodChecksInterface $paymentMethod, Quote $quote)
 {
     $total = $quote->getBaseGrandTotal();
     $minTotal = $paymentMethod->getConfigData(self::MIN_ORDER_TOTAL);
     $maxTotal = $paymentMethod->getConfigData(self::MAX_ORDER_TOTAL);
     if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) {
         return false;
     }
     return true;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:TotalMinMax.php


示例8: _getQuoteItemIdByProductId

 /**
  * Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
  *
  * @param \Magento\Quote\Model\Quote $quote
  * @param mixed $productId
  * @return \Magento\Quote\Model\Quote\Item|null
  */
 private function _getQuoteItemIdByProductId(\Magento\Quote\Model\Quote $quote, $productId)
 {
     /** @var $quoteItems \Magento\Quote\Model\Quote\Item[] */
     $quoteItems = $quote->getAllItems();
     foreach ($quoteItems as $quoteItem) {
         if ($productId == $quoteItem->getProductId()) {
             return $quoteItem;
         }
     }
     return null;
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:18,代码来源:CartTest.php


示例9: processShippingAssignment

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @return void
  * @throws InputException
  */
 private function processShippingAssignment($quote)
 {
     // Shipping Assignments processing
     $extensionAttributes = $quote->getExtensionAttributes();
     if (!$quote->isVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) {
         $shippingAssignments = $extensionAttributes->getShippingAssignments();
         if (count($shippingAssignments) > 1) {
             throw new InputException(__("Only 1 shipping assignment can be set"));
         }
         $this->shippingAssignmentPersister->save($quote, $shippingAssignments[0]);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:SaveHandler.php


示例10: fetch

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  * @return array
  */
 public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
 {
     $enabled = $this->helperData->isModuleEnabled();
     $minimumOrderAmount = $this->helperData->getMinimumOrderAmount();
     $subtotal = $quote->getSubtotal();
     $fee = $quote->getFee();
     if ($enabled && $minimumOrderAmount <= $subtotal && $fee) {
         return ['code' => 'fee', 'title' => 'Custom Fee', 'value' => $fee];
     } else {
         return array();
     }
 }
开发者ID:sivajik34,项目名称:Custom-Fee-Magento2,代码行数:17,代码来源:Fee.php


示例11: fetch

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Quote\Model\Quote\Address\Total $total
  * @return array
  */
 public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
 {
     $enabled = $this->helperData->isModuleEnabled();
     $minimumOrderAmount = $this->helperData->getMinimumOrderAmount();
     $subtotal = $quote->getSubtotal();
     $fee = $quote->getFee();
     $result = [];
     if ($enabled && $minimumOrderAmount <= $subtotal && $fee) {
         $result = ['code' => 'fee', 'title' => $this->helperData->getFeeLabel(), 'value' => $fee];
     }
     return $result;
 }
开发者ID:sivajik34,项目名称:Custom-Fee-Magento2,代码行数:17,代码来源:Fee.php


示例12: disabledQuoteAddressValidation

 /**
  * Make sure addresses will be saved without validation errors
  *
  * @param Quote $quote
  * @return void
  */
 protected function disabledQuoteAddressValidation(Quote $quote)
 {
     $billingAddress = $quote->getBillingAddress();
     $billingAddress->setShouldIgnoreValidation(true);
     if (!$quote->getIsVirtual()) {
         $shippingAddress = $quote->getShippingAddress();
         $shippingAddress->setShouldIgnoreValidation(true);
         if (!$billingAddress->getEmail()) {
             $billingAddress->setSameAsBilling(1);
         }
     }
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:18,代码来源:AbstractHelper.php


示例13: init

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\DataObject $config
  * @return \Magento\Quote\Model\Quote\Item|string
  */
 public function init(\Magento\Quote\Model\Quote $quote, \Magento\Catalog\Model\Product $product, \Magento\Framework\DataObject $config)
 {
     $stockItem = $this->stockRegistry->getStockItem($product->getId(), $quote->getStore()->getWebsiteId());
     if ($stockItem->getIsQtyDecimal()) {
         $product->setIsQtyDecimal(1);
     } else {
         $config->setQty((int) $config->getQty());
     }
     $product->setCartQty($config->getQty());
     $item = $quote->addProduct($product, $config, \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL);
     return $item;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:Initializer.php


示例14: getAvailableMethods

 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @return \Magento\Payment\Model\MethodInterface[]
  */
 public function getAvailableMethods(\Magento\Quote\Model\Quote $quote = null)
 {
     $store = $quote ? $quote->getStoreId() : null;
     $methods = [];
     $specification = $this->methodSpecificationFactory->create([AbstractMethod::CHECK_ZERO_TOTAL]);
     foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) {
         if ($this->_canUseMethod($method, $quote) && $specification->isApplicable($method, $quote)) {
             $method->setInfoInstance($quote->getPayment());
             $methods[] = $method;
         }
     }
     return $methods;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:MethodList.php


示例15: prepare

 public function prepare()
 {
     $this->contextMock = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false);
     $this->checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->orderFactoryMock = $this->getMock('Magento\\Sales\\Model\\OrderFactory', ['getQuote'], [], '', false);
     $this->hssHelperMock = $this->getMock('Magento\\Paypal\\Helper\\Hss', [], [], '', false);
     $this->paymentDataMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false);
     $this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['getPayment', '__wakeup'], [], '', false);
     $this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->any())->method('getPayment')->will($this->returnValue($this->paymentMock));
     $this->hssHelperMock->expects($this->any())->method('getHssMethods')->will($this->returnValue([]));
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:IframeTest.php


示例16: setUp

 public function setUp()
 {
     $objectManager = new ObjectManager($this);
     $this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
     $this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->quote = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
     $this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->address = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['__wakeup', 'getQuote', 'getShippingDiscountAmount', 'getBaseShippingDiscountAmount'])->getMock();
     $this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
     $methods = ['setType', 'setCode', 'setQuantity', 'setUnitPrice', 'setDiscountAmount', 'setTaxClassKey', 'setTaxIncluded', 'create'];
     $this->quoteDetailsItemBuilderMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemDataBuilder', $methods, [], '', false);
     $classMethods = ['setType', 'setValue', 'create'];
     $this->taxClassKeyBuilderMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyDataBuilder', $classMethods, [], '', false);
     $this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig, 'quoteDetailsItemBuilder' => $this->quoteDetailsItemBuilderMock, 'taxClassKeyBuilder' => $this->taxClassKeyBuilderMock]);
 }
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:15,代码来源:CommonTaxCollectorTest.php


示例17: setUp

 protected function setUp()
 {
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->orderMock = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
     $this->orderSenderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender\\OrderSender', [], [], '', false);
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getQuote', 'getOrder'])->getMock();
     $this->observerMock = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false);
     $this->observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
     $eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
     $this->quoteMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
     $this->model = new \Magento\Quote\Observer\Webapi\SubmitObserver($this->loggerMock, $this->orderSenderMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:SubmitObserverTest.php


示例18: add

 /**
  * @param array $giftMessages
  * @param \Magento\Quote\Model\Quote $quote
  * @return $this
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function add($giftMessages, $quote)
 {
     if (!is_array($giftMessages)) {
         return $this;
     }
     // types are 'quote', 'quote_item', etc
     foreach ($giftMessages as $type => $giftMessageEntities) {
         foreach ($giftMessageEntities as $entityId => $message) {
             $giftMessage = $this->messageFactory->create();
             switch ($type) {
                 case 'quote':
                     $entity = $quote;
                     break;
                 case 'quote_item':
                     $entity = $quote->getItemById($entityId);
                     break;
                 case 'quote_address':
                     $entity = $quote->getAddressById($entityId);
                     break;
                 case 'quote_address_item':
                     $entity = $quote->getAddressById($message['address'])->getItemById($entityId);
                     break;
                 default:
                     $entity = $quote;
                     break;
             }
             if ($entity->getGiftMessageId()) {
                 $giftMessage->load($entity->getGiftMessageId());
             }
             if (trim($message['message']) == '') {
                 if ($giftMessage->getId()) {
                     try {
                         $giftMessage->delete();
                         $entity->setGiftMessageId(0)->save();
                     } catch (\Exception $e) {
                     }
                 }
                 continue;
             }
             try {
                 $giftMessage->setSender($message['from'])->setRecipient($message['to'])->setMessage($message['message'])->setCustomerId($quote->getCustomerId())->save();
                 $entity->setGiftMessageId($giftMessage->getId())->save();
             } catch (\Exception $e) {
             }
         }
     }
     return $this;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:54,代码来源:GiftMessageManager.php


示例19: testExecuteWithSuccessOrderSave

 /**
  * Test for execute method
  *
  * @return void
  */
 public function testExecuteWithSuccessOrderSave()
 {
     $testData = $this->getExecuteWithSuccessOrderSaveTestData();
     $redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $paymentMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
     $checkoutMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods(['getRedirectUrl'])->getMock();
     $resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $redirectMock->expects($this->never())->method('setPath')->with('*/*/')->willReturn('redirect');
     $this->formKeyValidatorMock->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(true);
     $this->resultRedirectFactoryMock->expects($this->never())->method('create')->willReturn($redirectMock);
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap($testData['objectManager.get']);
     // call _expireAjax method
     $this->expireAjaxFlowHasItemsFalse();
     $this->requestMock->expects($this->atLeastOnce())->method('getPost')->willReturnMap($testData['request.getPost']);
     $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($testData['agreementsValidator.isValid'])->willReturn(true);
     $this->quoteMock->expects($this->atLeastOnce())->method('getPayment')->willReturn($paymentMock);
     $paymentMock->expects($this->once())->method('setQuote')->with($this->quoteMock);
     $paymentMock->expects($this->once())->method('importData')->with($testData['payment.importData']);
     $this->onepageMock->expects($this->once())->method('saveOrder');
     $this->onepageMock->expects($this->once())->method('getCheckout')->willReturn($checkoutMock);
     $checkoutMock->expects($this->once())->method('getRedirectUrl')->willReturn(null);
     $this->eventManagerMock->expects($this->once())->method('dispatch')->withConsecutive($this->equalTo('checkout_controller_onepage_saveOrder'), $this->countOf(2));
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($resultJsonMock);
     $resultJsonMock->expects($this->once())->method('setData')->with($testData['resultJson.setData'])->willReturnSelf();
     $this->assertEquals($resultJsonMock, $this->controller->execute());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:31,代码来源:SaveOrderTest.php


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Model\QuoteRepository类代码示例发布时间:2022-05-23
下一篇:
PHP Api\CartRepositoryInterface类代码示例发布时间: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