- This topic is empty.
-
AuthorPosts
-
January 21, 2016 at 5:46 am #9261
Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/u337135316/domains/bzotech.com/public_html/wp-includes/functions.php on line 6131
Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/u337135316/domains/bzotech.com/public_html/wp-includes/functions.php on line 6131
David Hoang
KeymasterIs there a way to show order information on success page after placing an order? The success phtml currently displays only order number information. The structure:
?> <?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?> <div class="checkout-success"> <?php if ($block->getOrderId()):?> <?php if ($block->getCanViewOrder()) :?> <p><?php echo __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p> <?php else :?> <p><?php echo __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p> <?php endif;?> <p><?php /* @escapeNotVerified */ echo __('We\'ll email you an order confirmation with details and tracking info.') ?></p> <?php endif;?> <?php echo $block->getAdditionalInfoHtml() ?> <div class="actions-toolbar"> <div class="primary"> <a class="action primary continue" href="<?php /* @escapeNotVerified */ echo $block->getUrl() ?>"><span><?php /* @escapeNotVerified */ echo __('Continue Shopping') ?></span></a> </div> </div> </div>I tried with calling the
getOrder() ?>function from sales module:Module_Sales/view/frontend/templates/order/view.phtmlbut it doesn’t work.April 18, 2016 at 8:22 am #9262
Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/u337135316/domains/bzotech.com/public_html/wp-includes/functions.php on line 6131
Deprecated: Function seems_utf8 is deprecated since version 6.9.0! Use wp_is_valid_utf8() instead. in /home/u337135316/domains/bzotech.com/public_html/wp-includes/functions.php on line 6131
David Hoang
KeymasterI’m about to do exactly the same thing, so I’ll just document every step.
Override block
Create the file
app/code/Vendor/Module/etc/di.xmland add the following:<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Checkout\Block\Onepage\Success" type="Vendor\Module\Block\Success"/> </config>Create the file
app/code/Vendor/Module/Block/Success.phpand add the following:<?php namespace Vendor\Module\Block; class Success extends \Magento\Checkout\Block\Onepage\Success { public function getOrder() { return $this->_checkoutSession->getLastRealOrder(); } }Override template
Create the file
app/code/Vendor/Module/view/frontend/layout/checkout_onepage_success.xmland add the following:<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.success" template="Your_Module::checkout/success.phtml"/> </body> </page>Create the file
app/code/Vendor/Module/view/frontend/templates/checkout/success.phtmland add the following:<?php /** @var $block \Vendor\Module\Block\Success */ ?> <div class="checkout-success"> <?php if ($block->getOrderId()):?> <?php if ($block->getCanViewOrder()) :?> <p><?php echo __('Your order number is: %1.', sprintf('<a href="%s" class="order-number"><strong>%s</strong></a>', $block->escapeHtml($block->getViewOrderUrl()), $block->escapeHtml($block->getOrderId()))) ?></p> <?php else: ?> <p><?php echo __('Your order # is: <span>%1</span>.', $block->escapeHtml($block->getOrderId())) ?></p> <?php endif; ?> <!-- BEGIN VENDOR_MODULE CUSTOM --> <p><?php echo __('You ordered %1 items.', (int) $block->getOrder()->getTotalQtyOrdered()) ?></p> <!-- END VENDOR_MODULE CUSTOM --> <p><?php /* @escapeNotVerified */ echo __('We\'ll email you an order confirmation with details and tracking info.') ?></p> <?php endif; ?> <?php echo $block->getAdditionalInfoHtml() ?> <div class="actions-toolbar"> <div class="primary"> <a class="action primary continue" href="<?php /* @escapeNotVerified */ echo $block->getUrl() ?>"><span><?php /* @escapeNotVerified */ echo __('Continue Shopping') ?></span></a> </div> </div> </div>That’s about it, hope I could be of any help.
Edit
You probably want to refresh your checkout/success page a lot, so to tackle that problem, go to file
app/code/Magento/Checkout/Controller/Onepage/Success.phpand change at line 22.$session->clearQuote();to
// $session->clearQuote();This way, your quote won’t get cleared when you open the page.
-
AuthorPosts
- You must be logged in to reply to this topic.