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


PHP Quote::getReservedOrderId方法代码示例

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


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

示例1: prepareOrderNumber

 private function prepareOrderNumber()
 {
     if ($this->proxyOrder->isOrderNumberPrefixSourceChannel()) {
         $orderNumber = $this->addPrefixToOrderNumberIfNeed($this->proxyOrder->getChannelOrderNumber());
         if ($this->getHelper('Magento')->isMagentoOrderIdUsed($orderNumber)) {
             $orderNumber .= '(1)';
         }
         $this->quote->setReservedOrderId($orderNumber);
         return;
     }
     $orderNumber = $this->quote->getReservedOrderId();
     if (empty($orderNumber)) {
         $orderNumber = $this->quote->getResource()->getReservedOrderId($this->quote);
     }
     $orderNumber = $this->addPrefixToOrderNumberIfNeed($orderNumber);
     if ($this->quote->getResource()->isOrderIncrementIdUsed($orderNumber)) {
         $orderNumber = $this->quote->getResource()->getReservedOrderId($this->quote);
     }
     $this->quote->setReservedOrderId($orderNumber);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:Quote.php

示例2: start

 /**
  * Reserve order ID for specified quote and start checkout on PayPal
  *
  * @param string $returnUrl
  * @param string $cancelUrl
  * @param bool|null $button
  * @return string
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function start($returnUrl, $cancelUrl, $button = null)
 {
     $this->_quote->collectTotals();
     if (!$this->_quote->getGrandTotal()) {
         throw new \Magento\Framework\Exception\LocalizedException(__('PayPal can\'t process orders with a zero balance due. ' . 'To finish your purchase, please go through the standard checkout process.'));
     }
     $this->_quote->reserveOrderId();
     $this->quoteRepository->save($this->_quote);
     // prepare API
     $this->_getApi();
     $solutionType = $this->_config->getMerchantCountry() == 'DE' ? \Magento\Paypal\Model\Config::EC_SOLUTION_TYPE_MARK : $this->_config->getValue('solutionType');
     $this->_api->setAmount($this->_quote->getBaseGrandTotal())->setCurrencyCode($this->_quote->getBaseCurrencyCode())->setInvNum($this->_quote->getReservedOrderId())->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl)->setSolutionType($solutionType)->setPaymentAction($this->_config->getValue('paymentAction'));
     if ($this->_giropayUrls) {
         list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
         $this->_api->addData(['giropay_cancel_url' => $cancelUrl, 'giropay_success_url' => $successUrl, 'giropay_bank_txn_pending_url' => $pendingUrl]);
     }
     if ($this->_isBml) {
         $this->_api->setFundingSource('BML');
     }
     $this->_setBillingAgreementRequest();
     if ($this->_config->getValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_ALL) {
         $this->_api->setRequireBillingAddress(1);
     }
     // suppress or export shipping address
     $address = null;
     if ($this->_quote->getIsVirtual()) {
         if ($this->_config->getValue('requireBillingAddress') == PaypalConfig::REQUIRE_BILLING_ADDRESS_VIRTUAL) {
             $this->_api->setRequireBillingAddress(1);
         }
         $this->_api->setSuppressShipping(true);
     } else {
         $address = $this->_quote->getShippingAddress();
         $isOverridden = 0;
         if (true === $address->validate()) {
             $isOverridden = 1;
             $this->_api->setAddress($address);
         }
         $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDDEN, $isOverridden);
         $this->_quote->getPayment()->save();
     }
     /** @var $cart \Magento\Payment\Model\Cart */
     $cart = $this->_cartFactory->create(['salesModel' => $this->_quote]);
     $this->_api->setPaypalCart($cart);
     if (!$this->_taxData->getConfig()->priceIncludesTax()) {
         $this->setShippingOptions($cart, $address);
     }
     $this->_config->exportExpressCheckoutStyleSettings($this->_api);
     /* Temporary solution. @TODO: do not pass quote into Nvp model */
     $this->_api->setQuote($this->_quote);
     $this->_api->callSetExpressCheckout();
     $token = $this->_api->getToken();
     $this->_setRedirectUrl($button, $token);
     $payment = $this->_quote->getPayment();
     $payment->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
     // Set flag that we came from Express Checkout button
     if (!empty($button)) {
         $payment->setAdditionalInformation(self::PAYMENT_INFO_BUTTON, 1);
     } elseif ($payment->hasAdditionalInformation(self::PAYMENT_INFO_BUTTON)) {
         $payment->unsAdditionalInformation(self::PAYMENT_INFO_BUTTON);
     }
     $payment->save();
     return $token;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:75,代码来源:Checkout.php


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