本文整理汇总了PHP中Magento\Checkout\Model\Session::getLastOrderId方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getLastOrderId方法的具体用法?PHP Session::getLastOrderId怎么用?PHP Session::getLastOrderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Checkout\Model\Session
的用法示例。
在下文中一共展示了Session::getLastOrderId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
/**
* @return bool
*/
public function isValid()
{
if (!$this->checkoutSession->getLastSuccessQuoteId()) {
return false;
}
if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLastOrderId()) {
return false;
}
return true;
}
示例2: getPostData
public function getPostData()
{
$orderId = $this->_checkoutSession->getLastOrderId();
if ($orderId) {
$incrementId = $this->_checkoutSession->getLastRealOrderId();
return $this->Config->getPostData($incrementId);
}
}
示例3: getOrder
/**
* @return \Magento\Sales\Model\Order
*/
public function getOrder()
{
if ($this->_order == null) {
$this->_order = $this->_orderFactory->create()->load($this->_checkoutSession->getLastOrderId());
}
return $this->_order;
}
示例4: executeInternal
/**
* Execute request
*
* @throws AlreadyExistsException
* @throws NoSuchEntityException
* @throws \Exception
* @return void
*/
public function executeInternal()
{
if ($this->customerSession->isLoggedIn()) {
$this->messageManager->addError(__("Customer is already registered"));
return;
}
$orderId = $this->checkoutSession->getLastOrderId();
if (!$orderId) {
$this->messageManager->addError(__("Your session has expired"));
return;
}
try {
$this->orderCustomerService->create($orderId);
} catch (\Exception $e) {
$this->messageManager->addException($e, $e->getMessage());
throw $e;
}
}
示例5: execute
/**
* Execute request
*
* @throws AlreadyExistsException
* @throws NoSuchEntityException
* @throws \Exception
* @return \Magento\Framework\Controller\Result\Json
*/
public function execute()
{
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
$resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\JsonFactory::class)->create();
if ($this->customerSession->isLoggedIn()) {
return $resultJson->setData(['errors' => true, 'message' => __('Customer is already registered')]);
}
$orderId = $this->checkoutSession->getLastOrderId();
if (!$orderId) {
return $resultJson->setData(['errors' => true, 'message' => __('Your session has expired')]);
}
try {
$this->orderCustomerService->create($orderId);
return $resultJson->setData(['errors' => false, 'message' => __('A letter with further instructions will be sent to your email.')]);
} catch (\Exception $e) {
$this->messageManager->addException($e, $e->getMessage());
throw $e;
}
}
示例6: isValid
/**
* Is valid session?
*
* @param \Magento\Checkout\Model\Session $checkoutSession
* @return bool
*/
public function isValid(\Magento\Checkout\Model\Session $checkoutSession)
{
if (!$checkoutSession->getLastSuccessQuoteId()) {
return false;
}
if (!$checkoutSession->getLastQuoteId() || !$checkoutSession->getLastOrderId()) {
return false;
}
return true;
}
示例7: isValid
/**
* Is valid session?
*
* @param \Magento\Checkout\Model\Session $checkoutSession
* @return bool
*/
public function isValid(\Magento\Checkout\Model\Session $checkoutSession)
{
if (!$checkoutSession->getLastSuccessQuoteId()) {
return false;
}
if (!$checkoutSession->getLastQuoteId() || !$checkoutSession->getLastOrderId() && count($checkoutSession->getLastRecurringPaymentIds()) == 0) {
return false;
}
return true;
}
示例8: getOrderIdForPaymentStart
/**
* @return int|false
*/
public function getOrderIdForPaymentStart()
{
if ($this->checkoutSuccessValidator->isValid()) {
return $this->checkoutSession->getLastOrderId();
}
$orderId = $this->request->getParam('id');
if ($orderId) {
return $orderId;
}
return false;
}
示例9: _prepareLastOrder
/**
* Get last order ID from session, fetch it and check whether it can be viewed, printed etc
*
* @return void
*/
protected function _prepareLastOrder()
{
$orderId = $this->_checkoutSession->getLastOrderId();
if ($orderId) {
$order = $this->_orderFactory->create()->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getStatus(), $this->_orderConfig->getInvisibleOnFrontStatuses());
$canView = $this->httpContext->getValue(Context::CONTEXT_AUTH) && $isVisible;
$this->addData(['is_order_visible' => $isVisible, 'view_order_url' => $this->getUrl('sales/order/view/', ['order_id' => $orderId]), 'print_url' => $this->getUrl('sales/order/print', ['order_id' => $orderId]), 'can_print_order' => $isVisible, 'can_view_order' => $canView, 'order_id' => $order->getIncrementId()]);
}
}
}
示例10: validateAddresses
/**
* Validate order addresses
*
* @return bool
*/
protected function validateAddresses()
{
$order = $this->orderRepository->get($this->checkoutSession->getLastOrderId());
$addresses = $order->getAddresses();
foreach ($addresses as $address) {
$result = $this->addressValidator->validateForCustomer($address);
if (is_array($result) && !empty($result)) {
return false;
}
}
return true;
}