Magento 2 Success.phtml output order values











up vote
0
down vote

favorite












We're having some issues with Magento 2 where we're unable to output the order values in our checkout code. Here's our code:



    <!---- Onefeed Tracking Code ---->
<?php
//-------------------------------------------
// GET MAGENTO ORDER VALUES FOR TRACKING CODE
//-------------------------------------------
$orderId = $block->escapeHtml($block->getOrderId());
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
$total = $order->getGrandTotal();
?>

<script type="text/javascript" language="javascript">
var of_ssid = 'xxxx';
var cs = '<?php echo $total ?>';
var oi = '<?php echo $orderId; ?>';
var it = 1;
</script>

<script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
<noscript>
<img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=xxxx&cs=<?php echo $total ?>&it=1&oi=<?php echo $orderId; ?>" />
</noscript>

<!---- End Onefeed Tracking Code ---->


Any ideas how we can output the data without having to create a module in Magento 2?










share|improve this question


























    up vote
    0
    down vote

    favorite












    We're having some issues with Magento 2 where we're unable to output the order values in our checkout code. Here's our code:



        <!---- Onefeed Tracking Code ---->
    <?php
    //-------------------------------------------
    // GET MAGENTO ORDER VALUES FOR TRACKING CODE
    //-------------------------------------------
    $orderId = $block->escapeHtml($block->getOrderId());
    $objectManager = MagentoFrameworkAppObjectManager::getInstance();
    $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
    $total = $order->getGrandTotal();
    ?>

    <script type="text/javascript" language="javascript">
    var of_ssid = 'xxxx';
    var cs = '<?php echo $total ?>';
    var oi = '<?php echo $orderId; ?>';
    var it = 1;
    </script>

    <script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
    <noscript>
    <img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=xxxx&cs=<?php echo $total ?>&it=1&oi=<?php echo $orderId; ?>" />
    </noscript>

    <!---- End Onefeed Tracking Code ---->


    Any ideas how we can output the data without having to create a module in Magento 2?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      We're having some issues with Magento 2 where we're unable to output the order values in our checkout code. Here's our code:



          <!---- Onefeed Tracking Code ---->
      <?php
      //-------------------------------------------
      // GET MAGENTO ORDER VALUES FOR TRACKING CODE
      //-------------------------------------------
      $orderId = $block->escapeHtml($block->getOrderId());
      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
      $total = $order->getGrandTotal();
      ?>

      <script type="text/javascript" language="javascript">
      var of_ssid = 'xxxx';
      var cs = '<?php echo $total ?>';
      var oi = '<?php echo $orderId; ?>';
      var it = 1;
      </script>

      <script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
      <noscript>
      <img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=xxxx&cs=<?php echo $total ?>&it=1&oi=<?php echo $orderId; ?>" />
      </noscript>

      <!---- End Onefeed Tracking Code ---->


      Any ideas how we can output the data without having to create a module in Magento 2?










      share|improve this question













      We're having some issues with Magento 2 where we're unable to output the order values in our checkout code. Here's our code:



          <!---- Onefeed Tracking Code ---->
      <?php
      //-------------------------------------------
      // GET MAGENTO ORDER VALUES FOR TRACKING CODE
      //-------------------------------------------
      $orderId = $block->escapeHtml($block->getOrderId());
      $objectManager = MagentoFrameworkAppObjectManager::getInstance();
      $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
      $total = $order->getGrandTotal();
      ?>

      <script type="text/javascript" language="javascript">
      var of_ssid = 'xxxx';
      var cs = '<?php echo $total ?>';
      var oi = '<?php echo $orderId; ?>';
      var it = 1;
      </script>

      <script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
      <noscript>
      <img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=xxxx&cs=<?php echo $total ?>&it=1&oi=<?php echo $orderId; ?>" />
      </noscript>

      <!---- End Onefeed Tracking Code ---->


      Any ideas how we can output the data without having to create a module in Magento 2?







      magento magento2.2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 16:23









      Onefeed

      115




      115
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          This part of your code is definately working (just checked):



          <?php 
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
          $total = $order->getGrandTotal();
          ?>
          ...
          <?php echo $total ?>


          Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.



          I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:



          https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly






          share|improve this answer





















          • We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
            – Onefeed
            Nov 23 at 9:39












          • Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
            – Tobi
            Nov 23 at 12:27











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53434959%2fmagento-2-success-phtml-output-order-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          This part of your code is definately working (just checked):



          <?php 
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
          $total = $order->getGrandTotal();
          ?>
          ...
          <?php echo $total ?>


          Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.



          I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:



          https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly






          share|improve this answer





















          • We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
            – Onefeed
            Nov 23 at 9:39












          • Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
            – Tobi
            Nov 23 at 12:27















          up vote
          0
          down vote













          This part of your code is definately working (just checked):



          <?php 
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
          $total = $order->getGrandTotal();
          ?>
          ...
          <?php echo $total ?>


          Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.



          I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:



          https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly






          share|improve this answer





















          • We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
            – Onefeed
            Nov 23 at 9:39












          • Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
            – Tobi
            Nov 23 at 12:27













          up vote
          0
          down vote










          up vote
          0
          down vote









          This part of your code is definately working (just checked):



          <?php 
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
          $total = $order->getGrandTotal();
          ?>
          ...
          <?php echo $total ?>


          Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.



          I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:



          https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly






          share|improve this answer












          This part of your code is definately working (just checked):



          <?php 
          $objectManager = MagentoFrameworkAppObjectManager::getInstance();
          $order = $objectManager->create('MagentoSalesModelOrder')->load($orderId);
          $total = $order->getGrandTotal();
          ?>
          ...
          <?php echo $total ?>


          Since I don't know which Block functions you are relying on it's impossible to say for sure, but I'm guessing $orderId = $block->escapeHtml($block->getOrderId()); does not return a valid order id.



          I'm not sure if you should use objectManager though. There is quite a discussion about when and how to use it on the stackexchange:



          https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 at 8:02









          Tobi

          816




          816












          • We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
            – Onefeed
            Nov 23 at 9:39












          • Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
            – Tobi
            Nov 23 at 12:27


















          • We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
            – Onefeed
            Nov 23 at 9:39












          • Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
            – Tobi
            Nov 23 at 12:27
















          We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
          – Onefeed
          Nov 23 at 9:39






          We do have a valid Order ID, this is being collected in the checkout call. The order total is null and is not returning any values. I think the site is using the standard Block functions. We have no customized values on this page.
          – Onefeed
          Nov 23 at 9:39














          Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
          – Tobi
          Nov 23 at 12:27




          Magento 2 comes with a standard google analytics and adwords module. For conversion tracking they refer to a helper class in the adwords module. You can see the implementation in module-google-adwords/view/frontend/templates/code.phtml. Maybe you can compare this to your usecase to find what's causing the problem.
          – Tobi
          Nov 23 at 12:27


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fstackoverflow.com%2fquestions%2f53434959%2fmagento-2-success-phtml-output-order-values%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

          Trompette piccolo

          Slow SSRS Report in dynamic grouping and multiple parameters

          Simon Yates (cyclisme)