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


PHP Session::getLastRealOrder方法代码示例

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


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

示例1: getOrder

 public function getOrder()
 {
     if (!$this->_order) {
         $this->_order = $this->_checkoutSession->getLastRealOrder();
     }
     return $this->_order;
 }
开发者ID:vuleticd,项目名称:vuleticd_assist2,代码行数:7,代码来源:Payment.php

示例2: cancelCurrentOrder

 /**
  * Cancel last placed order with specified comment message
  *
  * @param string $comment Comment appended to order history
  * @return bool True if order cancelled, false otherwise
  */
 public function cancelCurrentOrder($comment)
 {
     $order = $this->session->getLastRealOrder();
     if ($order->getId() && $order->getState() != Order::STATE_CANCELED) {
         $order->registerCancellation($comment)->save();
         return true;
     }
     return false;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Checkout.php

示例3: __construct

 /**
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param \Magento\Checkout\Model\Session $checkoutSession
  * @param \Yireo\GoogleTagManager2\Helper\Data $helper
  * @param \Yireo\GoogleTagManager2\Model\Container $container
  * @param array $data
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Yireo\GoogleTagManager2\Helper\Data $helper, \Yireo\GoogleTagManager2\Model\Container $container, array $data = [])
 {
     $this->helper = $helper;
     $this->container = $container;
     $this->checkoutSession = $checkoutSession;
     $this->order = $this->checkoutSession->getLastRealOrder();
     $this->quote = $this->checkoutSession->getQuote();
     parent::__construct($context, $data);
     $this->storeManager = $this->_storeManager;
     $this->layout = $this->_layout;
 }
开发者ID:yireo,项目名称:Yireo_GoogleTagManager2,代码行数:18,代码来源:Generic.php

示例4: execute

 /**
  * Redirect to payment
  *
  * @return \Magento\Framework\Controller\Result\Redirect
  */
 public function execute()
 {
     try {
         return $this->_resultRedirectFactory->create()->setPath($this->_payment->createPaymentRequest());
     } catch (\Exception $exception) {
         /** @var \Magento\Sales\Model\Order $order */
         $order = $this->_objectManager->create('\\Magento\\Sales\\Model\\Order')->load($this->_checkoutSession->getLastRealOrder()->getId());
         /** change payment status in magento */
         $order->addStatusToHistory('pagseguro_cancelada', null, true);
         /** save order */
         $order->save();
         return $this->_redirect('pagseguro/payment/failure');
     }
 }
开发者ID:pagseguro,项目名称:magento2,代码行数:19,代码来源:Request.php

示例5: testGetLastRealOrder

 /**
  * @param int|null $orderId
  * @param int|null $incrementId
  * @param \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject $orderMock
  * @dataProvider getLastRealOrderDataProvider
  */
 public function testGetLastRealOrder($orderId, $incrementId, $orderMock)
 {
     $orderFactory = $this->getMockBuilder('Magento\\Sales\\Model\\OrderFactory')->disableOriginalConstructor()->setMethods(array('create'))->getMock();
     $orderFactory->expects($this->once())->method('create')->will($this->returnValue($orderMock));
     $messageCollectionFactory = $this->getMockBuilder('Magento\\Framework\\Message\\CollectionFactory')->disableOriginalConstructor()->getMock();
     $quoteFactory = $this->getMockBuilder('Magento\\Sales\\Model\\QuoteFactory')->disableOriginalConstructor()->getMock();
     $appState = $this->getMock('\\Magento\\Framework\\App\\State', array(), array(), '', false);
     $appState->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
     $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', array(), array(), '', false);
     $request->expects($this->any())->method('getHttpHost')->will($this->returnValue(array()));
     $constructArguments = $this->_helper->getConstructArguments('Magento\\Checkout\\Model\\Session', array('request' => $request, 'orderFactory' => $orderFactory, 'messageCollectionFactory' => $messageCollectionFactory, 'quoteFactory' => $quoteFactory, 'storage' => new \Magento\Framework\Session\Storage()));
     $this->_session = $this->_helper->getObject('Magento\\Checkout\\Model\\Session', $constructArguments);
     $this->_session->setLastRealOrderId($orderId);
     $this->assertSame($orderMock, $this->_session->getLastRealOrder());
     if ($orderId == $incrementId) {
         $this->assertSame($orderMock, $this->_session->getLastRealOrder());
     }
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:24,代码来源:SessionTest.php

示例6: getVariables

 /**
  * Return order and it's item related variables
  *
  * @return array
  */
 public function getVariables()
 {
     $variables = [];
     $order = $order = $this->checkoutSession->getLastRealOrder();
     if ($order) {
         $variables['order.id'] = $order->getIncrementId();
         $variables['order.subtotal'] = $order->getBaseSubtotalInclTax();
         $variables['order.discount_total'] = $order->getDiscountAmount();
         $variables['order.shipping_total'] = $order->getShippingAmount();
         $variables['order.grand_total'] = $order->getBaseGrandTotal();
         $variables['order.shipping_method'] = $order->getShippingMethod();
         $variables['order.payment_method'] = $order->getPayment()->getMethod();
         $variables['order.salesrules'] = $order->getAppliedRuleIds();
         foreach ($order->getAllItems() as $item) {
             $variables = array_merge($variables, $this->getOrderItemVariables($item));
         }
     }
     return $variables;
 }
开发者ID:smile-sa,项目名称:elasticsuite,代码行数:24,代码来源:Order.php

示例7: execute

 /**
  * Show payment page
  * @return \Magento\Framework\View\Result\PageFactory
  */
 public function execute()
 {
     $resultPage = $this->_resultPageFactory->create();
     $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('order', $this->_checkoutSession->getLastRealOrder()->getId());
     try {
         $this->_library->setEnvironment();
         $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('sessionCode', $this->_library->getSession());
         $resultPage->getLayout()->getBlock('pagseguro.direct.payment')->setData('paymentUrl', $this->_library->getDirectPaymentUrl());
     } catch (\Exception $exc) {
         /** @var \Magento\Sales\Model\Order $order */
         $order = $this->_objectManager->create('\\Magento\\Sales\\Model\\Order')->load($this->_checkoutSession->getLastRealOrder()->getId());
         /** change payment status in magento */
         $order->addStatusToHistory('pagseguro_cancelada', null, true);
         /** save order */
         $order->save();
         return $this->_redirect('pagseguro/payment/failure');
     }
     return $resultPage;
 }
开发者ID:pagseguro,项目名称:magento2,代码行数:23,代码来源:Payment.php

示例8: createOrder

 /**
  * create an order in ComproPago
  *
  * @return array
  */
 private function createOrder()
 {
     $order = $this->checSession->getLastRealOrder();
     $dataorder = new PlaceOrderInfo($order->getRealOrderId(), $order->getRealOrderId(), $order->getData('total_due'), $order->getCustomerFirstname() . " " . $order->getCustomerLastname(), $order->getCustomerEmail(), $_COOKIE['provider'], null, 'magento2', $this->metada->getVersion());
     if (isset($_COOKIE['payment_method']) && $_COOKIE['payment_method'] == 'compropago') {
         try {
             $client = new Client($this->instance->getPublicKey(), $this->instance->getPrivateKey(), $this->instance->getLiveMode());
             $response = $client->api->placeOrder($dataorder);
             $_COOKIE['provider'] = null;
             $_COOKIE['payment_method'] = null;
             unset($_COOKIE['provider']);
             unset($_COOKIE['payment_method']);
             return ["type" => "success", "value" => base64_encode($response->getId())];
         } catch (\Exception $e) {
             return ["type" => "error", "value" => $e->getMessage()];
         }
     } else {
         return ["type" => "error", "value" => "Metodo no reconocido"];
     }
 }
开发者ID:compropago,项目名称:plugin-magento-2,代码行数:25,代码来源:Receipt.php

示例9: _initCheckout

 /**
  * Instantiate
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _initCheckout()
 {
     $pre = __METHOD__ . " : ";
     $this->_logger->debug($pre . 'bof');
     $this->_order = $this->_checkoutSession->getLastRealOrder();
     if (!$this->_order->getId()) {
         $this->getResponse()->setStatusHeader(404, '1.1', 'Not found');
         throw new \Magento\Framework\Exception\LocalizedException(__('We could not find "Order" for processing'));
     }
     if ($this->_order->getState() != \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) {
         $this->_order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT)->save();
     }
     if ($this->_order->getQuoteId()) {
         $this->_checkoutSession->setPayfastQuoteId($this->_checkoutSession->getQuoteId());
         $this->_checkoutSession->setPayfastSuccessQuoteId($this->_checkoutSession->getLastSuccessQuoteId());
         $this->_checkoutSession->setPayfastRealOrderId($this->_checkoutSession->getLastRealOrderId());
         $this->_checkoutSession->getQuote()->setIsActive(false)->save();
         //$this->_checkoutSession->clear();
     }
     $this->_logger->debug($pre . 'eof');
     //$this->_checkout = $this->_checkoutTypes[$this->_checkoutType];
 }
开发者ID:PayFast,项目名称:mod-magento_2,代码行数:28,代码来源:AbstractPayfast.php

示例10: getStandardCheckoutFormFields

 /**
  * this where we compile data posted by the form to payfast
  * @return array
  */
 public function getStandardCheckoutFormFields()
 {
     $pre = __METHOD__ . ' : ';
     // Variable initialization
     $order = $this->_checkoutSession->getLastRealOrder();
     $description = '';
     $this->_logger->debug($pre . 'serverMode : ' . $this->getConfigData('server'));
     // If NOT test mode, use normal credentials
     if ($this->getConfigData('server') == 'live') {
         $merchantId = $this->getConfigData('merchant_id');
         $merchantKey = $this->getConfigData('merchant_key');
     } else {
         $merchantId = '10000100';
         $merchantKey = '46f0cd694581a';
     }
     // Create description
     foreach ($order->getAllItems() as $items) {
         $description .= $this->getNumberFormat($items->getQtyOrdered()) . ' x ' . $items->getName() . ';';
     }
     $pfDescription = trim(substr($description, 0, 254));
     // Construct data for the form
     $data = array('merchant_id' => $merchantId, 'merchant_key' => $merchantKey, 'return_url' => $this->getPaidSuccessUrl(), 'cancel_url' => $this->getPaidCancelUrl(), 'notify_url' => $this->getPaidNotifyUrl(), 'name_first' => $order->getData('customer_firstname'), 'name_last' => $order->getData('customer_lastname'), 'email_address' => $order->getData('customer_email'), 'm_payment_id' => $order->getRealOrderId(), 'amount' => $this->getTotalAmount($order), 'item_name' => $this->_storeManager->getStore()->getName() . ', Order #' . $order->getRealOrderId(), 'item_description' => $pfDescription);
     $pfOutput = '';
     // Create output string
     foreach ($data as $key => $val) {
         if (!empty($val)) {
             $pfOutput .= $key . '=' . urlencode($val) . '&';
         }
     }
     $passPhrase = $this->getConfigData('passphrase');
     $pfOutput = substr($pfOutput, 0, -1);
     if (!empty($passPhrase) && $this->getConfigData('server') !== 'test') {
         $pfOutput = $pfOutput . "&passphrase=" . urlencode($passPhrase);
     }
     pflog($pre . 'pfOutput for signature is : ' . $pfOutput);
     $pfSignature = md5($pfOutput);
     $data['signature'] = $pfSignature;
     $data['user_agent'] = 'Magento 2.0';
     pflog($pre . 'data is :' . print_r($data, true));
     return $data;
 }
开发者ID:PayFast,项目名称:mod-magento_2,代码行数:45,代码来源:Payfast.php

示例11: __construct

 /**
  * Constructor
  *
  * @param Template\Context $context
  * @param CheckoutSession $checkoutSession
  * @param array $data
  */
 public function __construct(Template\Context $context, CheckoutSession $checkoutSession, array $data = [])
 {
     $this->orderPayment = $checkoutSession->getLastRealOrder()->getPayment();
     parent::__construct($context, $data);
 }
开发者ID:fontis,项目名称:australia-mage2,代码行数:12,代码来源:CheckoutSuccess.php

示例12: getAmount

 /**
  * Get order amount (subtotal)
  * @return Float
  * @author edudeleon
  * @date   2015-08-07
  */
 public function getAmount()
 {
     //Get last order from session
     $order = $this->_checkoutSession->getLastRealOrder();
     return number_format($order->getSubtotal(), 2);
 }
开发者ID:addshoppers,项目名称:Magento2,代码行数:12,代码来源:Roi.php

示例13: getEmailAddress

 /**
  * Retrieve current email address
  *
  * @return string
  * @codeCoverageIgnore
  */
 public function getEmailAddress()
 {
     return $this->checkoutSession->getLastRealOrder()->getCustomerEmail();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:Registration.php

示例14: prepareBlockData

 /**
  * Prepares block data
  *
  * @return void
  */
 protected function prepareBlockData()
 {
     $order_is_ok = true;
     $order_error_message = '';
     if (!($order = $this->_checkoutSession->getLastRealOrder())) {
         $order_error_message = __('Couldn\'t extract order information.');
     } elseif ($order->getState() != Order::STATE_NEW) {
         $order_error_message = __('Order was already processed or session information expired.');
     } elseif (!($additional_info = $order->getPayment()->getAdditionalInformation()) or !is_array($additional_info) or empty($additional_info['sp_method']) or empty($additional_info['sp_transaction'])) {
         $order_error_message = __('Couldn\'t extract payment information from order.');
     }
     if (!empty($order_error_message)) {
         $order_is_ok = false;
     }
     $smart2pay_config = $this->_s2pModel->getFullConfigArray();
     $merchant_transaction_id = $order->getRealOrderId();
     // assume live environment if we don't get something valid from config
     if (empty($smart2pay_config['environment']) or !($environment = Environment::validEnvironment($smart2pay_config['environment']))) {
         $environment = Environment::ENV_LIVE;
     }
     if ($environment == Environment::ENV_DEMO) {
         $merchant_transaction_id = $this->_helper->convert_to_demo_merchant_transaction_id($merchant_transaction_id);
     }
     $form_data = $smart2pay_config;
     if ($order_is_ok) {
         $form_data['environment'] = $environment;
         $form_data['method_id'] = !empty($additional_info['sp_method']) ? intval($additional_info['sp_method']) : 0;
         $form_data['order_id'] = $merchant_transaction_id;
         $form_data['currency'] = $order->getOrderCurrency()->getCurrencyCode();
         $form_data['amount'] = number_format($order->getGrandTotal(), 2, '.', '') * 100;
         //anonymous user, get the info from billing details
         if ($order->getCustomerId() === null) {
             $form_data['customer_last_name'] = $this->_helper->s2p_mb_substr($order->getBillingAddress()->getLastname(), 0, 30);
             $form_data['customer_first_name'] = $this->_helper->s2p_mb_substr($order->getBillingAddress()->getFirstname(), 0, 30);
             $form_data['customer_name'] = $this->_helper->s2p_mb_substr($form_data['customer_first_name'] . ' ' . $form_data['customer_last_name'], 0, 30);
         } else {
             $form_data['customer_name'] = $this->_helper->s2p_mb_substr($order->getCustomerName(), 0, 30);
             $form_data['customer_last_name'] = $this->_helper->s2p_mb_substr($order->getCustomerLastname(), 0, 30);
             $form_data['customer_first_name'] = $this->_helper->s2p_mb_substr($order->getCustomerFirstname(), 0, 30);
         }
         $form_data['customer_email'] = trim($order->getCustomerEmail());
         $form_data['country'] = $order->getBillingAddress()->getCountryId();
         $messageToHash = 'MerchantID' . $form_data['mid'] . 'MerchantTransactionID' . $form_data['order_id'] . 'Amount' . $form_data['amount'] . 'Currency' . $form_data['currency'] . 'ReturnURL' . $form_data['return_url'];
         if ($form_data['site_id']) {
             $messageToHash .= 'SiteID' . $form_data['site_id'];
         }
         $messageToHash .= 'CustomerName' . $form_data['customer_name'];
         $messageToHash .= 'CustomerLastName' . $form_data['customer_last_name'];
         $messageToHash .= 'CustomerFirstName' . $form_data['customer_first_name'];
         $messageToHash .= 'CustomerEmail' . $form_data['customer_email'];
         $messageToHash .= 'Country' . $form_data['country'];
         $messageToHash .= 'MethodID' . $form_data['method_id'];
         $form_data['order_description'] = 'Ref. no.: ' . $form_data['order_id'];
         if (empty($form_data['product_description_ref'])) {
             $form_data['order_description'] = $form_data['product_description_custom'];
         }
         $messageToHash .= 'Description' . $form_data['order_description'];
         $form_data['skip_hpp'] = 0;
         if ($form_data['skip_payment_page'] and (!in_array($form_data['method_id'], [Smart2Pay::PAYMENT_METHOD_BT, Smart2Pay::PAYMENT_METHOD_SIBS]) or $form_data['notify_payment_instructions'])) {
             $form_data['skip_hpp'] = 1;
             $messageToHash .= 'SkipHpp1';
         }
         if ($form_data['redirect_in_iframe']) {
             $messageToHash .= 'RedirectInIframe1';
         }
         if ($form_data['skin_id']) {
             $messageToHash .= 'SkinID' . $form_data['skin_id'];
         }
         $messageToHash .= $form_data['signature'];
         $form_data['message_to_hash'] = $this->_helper->s2p_mb_strtolower($messageToHash);
         $form_data['hash'] = $this->_helper->computeSHA256Hash($messageToHash);
         $this->_s2pLogger->write('Form hash: [' . $messageToHash . ']', 'info');
         $s2p_transaction = $this->_s2pTransaction->create();
         $s2p_transaction->setID($additional_info['sp_transaction'])->setMethodID($form_data['method_id'])->setMerchantTransactionID($form_data['order_id'])->setSiteID($form_data['site_id'])->setEnvironment($form_data['environment']);
         $s2p_transaction->save();
         $order->addStatusHistoryComment('Smart2Pay :: redirecting to payment page with MethodID: ' . $form_data['method_id']);
         $order->save();
     }
     $this->addData(['order_ok' => $order_is_ok, 'error_message' => $order_error_message, 'order_id' => $order->getIncrementId(), 'form_data' => $form_data]);
 }
开发者ID:smart2pay,项目名称:magento20,代码行数:85,代码来源:Send.php

示例15: getOrderUrl

 /**
  * Return a url to go to order detail page
  *
  * @return string
  */
 public function getOrderUrl()
 {
     $params = ['order_id' => $this->_checkoutSession->getLastRealOrder()->getId()];
     $url = $this->_urlBuilder->getUrl('sales/order/view', $params);
     return $url;
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:11,代码来源:AbstractSuccess.php


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