Summary of purchase on the success page
I wanted to summarize the purchase on the success page, as if it were a cart with all the products that the user bought, with the image, product name, quantity and price of it. From the code below I can see how many products are in the cart, but I can not get them and assemble the HTML portion of this summary.Thanks in advance.
$order = Mage::getSingleton('sales/order');
$order->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$_items = $order->getAllItems();
echo count($_items);
magento-1.9 product cart orders purchase-order
add a comment |
I wanted to summarize the purchase on the success page, as if it were a cart with all the products that the user bought, with the image, product name, quantity and price of it. From the code below I can see how many products are in the cart, but I can not get them and assemble the HTML portion of this summary.Thanks in advance.
$order = Mage::getSingleton('sales/order');
$order->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$_items = $order->getAllItems();
echo count($_items);
magento-1.9 product cart orders purchase-order
add a comment |
I wanted to summarize the purchase on the success page, as if it were a cart with all the products that the user bought, with the image, product name, quantity and price of it. From the code below I can see how many products are in the cart, but I can not get them and assemble the HTML portion of this summary.Thanks in advance.
$order = Mage::getSingleton('sales/order');
$order->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$_items = $order->getAllItems();
echo count($_items);
magento-1.9 product cart orders purchase-order
I wanted to summarize the purchase on the success page, as if it were a cart with all the products that the user bought, with the image, product name, quantity and price of it. From the code below I can see how many products are in the cart, but I can not get them and assemble the HTML portion of this summary.Thanks in advance.
$order = Mage::getSingleton('sales/order');
$order->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
$_items = $order->getAllItems();
echo count($_items);
magento-1.9 product cart orders purchase-order
magento-1.9 product cart orders purchase-order
asked Nov 13 '17 at 15:43
Matheus PortelaMatheus Portela
292214
292214
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Try below code.
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
?>
<table>
<tr>
<th><?php echo $this->__('Description') ?></th
<th><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Qty') ?></th>
<th><?php echo $this->__('Unit Price') ?></th>
</tr>
<?php foreach($order_details->getAllVisibleItems() as $item):
$configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
<td><?php echo $item->getName() ?></td>
<td><?php echo round($item->getQtyOrdered(), 0) ?></td>
<td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
</tr>
<?php endforeach ?>
</table>
add a comment |
Override /app/code/Mage/Checkout/Block/Onepage/Success.php with your local copy. and edit the following method below. This will include the items in the success block.
protected function _prepareLastOrder()
{
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getState(),
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
$this->addData(array(
'is_order_visible' => $isVisible,
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
'can_print_order' => $isVisible,
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
'order_id' => $order->getIncrementId(),
'all_items' => $order->getAllItems(),
));
}
}
}
You should notice the line 'all_items' => $order->getAllItems(),
And then in your success.phtml file, you can access all of the items in an order.
$items = array();
foreach ($this->getAllItems() as $item) {
$items['id'] = $item->getProductId();
$items['price'] = $item->getPrice();
$items['quantity'] = $item->getQtyOrdered();
}
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f201272%2fsummary-of-purchase-on-the-success-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try below code.
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
?>
<table>
<tr>
<th><?php echo $this->__('Description') ?></th
<th><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Qty') ?></th>
<th><?php echo $this->__('Unit Price') ?></th>
</tr>
<?php foreach($order_details->getAllVisibleItems() as $item):
$configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
<td><?php echo $item->getName() ?></td>
<td><?php echo round($item->getQtyOrdered(), 0) ?></td>
<td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
</tr>
<?php endforeach ?>
</table>
add a comment |
Try below code.
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
?>
<table>
<tr>
<th><?php echo $this->__('Description') ?></th
<th><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Qty') ?></th>
<th><?php echo $this->__('Unit Price') ?></th>
</tr>
<?php foreach($order_details->getAllVisibleItems() as $item):
$configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
<td><?php echo $item->getName() ?></td>
<td><?php echo round($item->getQtyOrdered(), 0) ?></td>
<td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
</tr>
<?php endforeach ?>
</table>
add a comment |
Try below code.
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
?>
<table>
<tr>
<th><?php echo $this->__('Description') ?></th
<th><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Qty') ?></th>
<th><?php echo $this->__('Unit Price') ?></th>
</tr>
<?php foreach($order_details->getAllVisibleItems() as $item):
$configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
<td><?php echo $item->getName() ?></td>
<td><?php echo round($item->getQtyOrdered(), 0) ?></td>
<td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
</tr>
<?php endforeach ?>
</table>
Try below code.
<?php
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id);
?>
<table>
<tr>
<th><?php echo $this->__('Description') ?></th
<th><?php echo $this->__('Description') ?></th>
<th><?php echo $this->__('Qty') ?></th>
<th><?php echo $this->__('Unit Price') ?></th>
</tr>
<?php foreach($order_details->getAllVisibleItems() as $item):
$configItem = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
?>
<tr>
<td><img src="<?php echo $this->helper('catalog/image')->init($configItem, 'small_image')->resize(200); ?>" width="200" height="200" class="media-object img-responsive" alt="<?php echo $this->getImageLabel($configItem, 'small_image'); ?>"/></td>
<td><?php echo $item->getName() ?></td>
<td><?php echo round($item->getQtyOrdered(), 0) ?></td>
<td><?php echo Mage::helper("core")->currency($item->getPrice()) ?></td>
</tr>
<?php endforeach ?>
</table>
edited Nov 14 '17 at 15:47
Matheus Portela
292214
292214
answered Nov 13 '17 at 15:46
Abhishek PanchalAbhishek Panchal
3,4783929
3,4783929
add a comment |
add a comment |
Override /app/code/Mage/Checkout/Block/Onepage/Success.php with your local copy. and edit the following method below. This will include the items in the success block.
protected function _prepareLastOrder()
{
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getState(),
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
$this->addData(array(
'is_order_visible' => $isVisible,
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
'can_print_order' => $isVisible,
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
'order_id' => $order->getIncrementId(),
'all_items' => $order->getAllItems(),
));
}
}
}
You should notice the line 'all_items' => $order->getAllItems(),
And then in your success.phtml file, you can access all of the items in an order.
$items = array();
foreach ($this->getAllItems() as $item) {
$items['id'] = $item->getProductId();
$items['price'] = $item->getPrice();
$items['quantity'] = $item->getQtyOrdered();
}
New contributor
add a comment |
Override /app/code/Mage/Checkout/Block/Onepage/Success.php with your local copy. and edit the following method below. This will include the items in the success block.
protected function _prepareLastOrder()
{
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getState(),
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
$this->addData(array(
'is_order_visible' => $isVisible,
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
'can_print_order' => $isVisible,
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
'order_id' => $order->getIncrementId(),
'all_items' => $order->getAllItems(),
));
}
}
}
You should notice the line 'all_items' => $order->getAllItems(),
And then in your success.phtml file, you can access all of the items in an order.
$items = array();
foreach ($this->getAllItems() as $item) {
$items['id'] = $item->getProductId();
$items['price'] = $item->getPrice();
$items['quantity'] = $item->getQtyOrdered();
}
New contributor
add a comment |
Override /app/code/Mage/Checkout/Block/Onepage/Success.php with your local copy. and edit the following method below. This will include the items in the success block.
protected function _prepareLastOrder()
{
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getState(),
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
$this->addData(array(
'is_order_visible' => $isVisible,
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
'can_print_order' => $isVisible,
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
'order_id' => $order->getIncrementId(),
'all_items' => $order->getAllItems(),
));
}
}
}
You should notice the line 'all_items' => $order->getAllItems(),
And then in your success.phtml file, you can access all of the items in an order.
$items = array();
foreach ($this->getAllItems() as $item) {
$items['id'] = $item->getProductId();
$items['price'] = $item->getPrice();
$items['quantity'] = $item->getQtyOrdered();
}
New contributor
Override /app/code/Mage/Checkout/Block/Onepage/Success.php with your local copy. and edit the following method below. This will include the items in the success block.
protected function _prepareLastOrder()
{
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
if ($orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->getId()) {
$isVisible = !in_array($order->getState(),
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
$this->addData(array(
'is_order_visible' => $isVisible,
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
'can_print_order' => $isVisible,
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
'order_id' => $order->getIncrementId(),
'all_items' => $order->getAllItems(),
));
}
}
}
You should notice the line 'all_items' => $order->getAllItems(),
And then in your success.phtml file, you can access all of the items in an order.
$items = array();
foreach ($this->getAllItems() as $item) {
$items['id'] = $item->getProductId();
$items['price'] = $item->getPrice();
$items['quantity'] = $item->getQtyOrdered();
}
New contributor
New contributor
answered 25 mins ago
Magento DeveloperMagento Developer
11
11
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f201272%2fsummary-of-purchase-on-the-success-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown