Summary of purchase on the success page












0















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);









share|improve this question



























    0















    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);









    share|improve this question

























      0












      0








      0








      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);









      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '17 at 15:43









      Matheus PortelaMatheus Portela

      292214




      292214






















          2 Answers
          2






          active

          oldest

          votes


















          1














          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>





          share|improve this answer

































            0














            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();
            }





            share|improve this answer








            New contributor




            Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              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
              });


              }
              });














              draft saved

              draft discarded


















              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









              1














              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>





              share|improve this answer






























                1














                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>





                share|improve this answer




























                  1












                  1








                  1







                  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>





                  share|improve this answer















                  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>






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  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

























                      0














                      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();
                      }





                      share|improve this answer








                      New contributor




                      Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.

























                        0














                        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();
                        }





                        share|improve this answer








                        New contributor




                        Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0












                          0








                          0







                          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();
                          }





                          share|improve this answer








                          New contributor




                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          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();
                          }






                          share|improve this answer








                          New contributor




                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 25 mins ago









                          Magento DeveloperMagento Developer

                          11




                          11




                          New contributor




                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Magento Developer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              What other Star Trek series did the main TNG cast show up in?

                              Berlina muro

                              Berlina aerponto