Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Nov 2006
    Posts
    56
    Plugin Contributions
    0

    Default $order_summary values not showing up on checkout success

    I'm having trouble TAGGING on checkout success.

    Here's what I have for code:
    Code:
    <!-- CHECKOUT SUCCESS TAGGING -->
    
    
    <script type="text/javascript">
    tagging.event("order", {
      action: "purchase",
      order: {
        order_id: " <?php echo $order_summary['order_number']; ?>",
        total: <?php echo $order_summary['order_total']; ?>,
        discount: <?PHP echo $order_summary['credits_applied']; ?>,
        subtotal: <?PHP echo $order_summary['order_subtotal']; ?>,
        tax: <?PHP echo $order_summary['tax']; ?>,
        shipping: <?PHP echo $order_summary['shipping']; ?>,
        coupon_code: "<?PHP echo $order_summary['coupon_code']; ?>",
        items: [
        <? for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { ?>
          {
            product_id: "<?php echo $order->products[$i]['id']; ?>",
            price: <?php echo $order->products[$i]['final_price']; ?>,
            quantity: <?php echo $order->products[$i]['qty']; ?>,
            subtotal: <?php echo ($order->products[$i]['final_price']*$order->products[$i]['quantity']); ?>
          }
          <? if ($i == $n-1) {} else { echo ",";} ?>
          <? } ?>
        ]
      }
    });
    </script>
    
    
    <!-- END tagging-->
    I have this saved in a file:

    /includes/modules/pages/checkout_success

    BUT, here's what gets outputted:
    Code:
    <!-- CHECKOUT SUCCESS TAGGING -->
    
    
    <script type="text/javascript">
    tagging.event("order", {
      action: "purchase",
      order: {
        order_id: " ",
        total: ,
        discount: ,
        subtotal: ,
        tax: ,
        shipping: ,
        coupon_code: "",
        items: [
              {
            product_id: "168",
            price: 3.5000,
            quantity: 2,
            subtotal: 0      }
          ,            {
            product_id: "167",
            price: 5.7000,
            quantity: 1,
            subtotal: 0      }
                    ]
      }
    });
    </script>
    
    
    <!-- END tagging-->
    Notice that NONE of the $order_summary values are populated.

    I followed the details on this page:
    https://www.zen-cart.com/content.php...els-to-my-site



    Any help?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: $order_summary values not showing up on checkout success

    Since trying to use option 1.a) from the referenced document:

    What is the actual name of the file in that location? Does it begin with jscript_ and end with (have the extension of) .php?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2006
    Posts
    56
    Plugin Contributions
    0

    Default Re: $order_summary values not showing up on checkout success

    Bad copy and paste - I thought I included the actual file name:

    jscript_zaius_checkoutSuccess.php

    SO... YES it starts with jscirpt and YES it is a PHP file.

    And I know the file is included and working as it is successfully outputting item in the order using the $order->products[$i] variable...

    Just $order_summary isn't working as it is supposed to work?


  4. #4
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: $order_summary values not showing up on checkout success

    What version of ZC?

    Could maybe try adding at the top of your file:
    Code:
    <pre><?php echo print_r($order_summary, true); ?></pre>
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Nov 2006
    Posts
    56
    Plugin Contributions
    0

    Default Re: $order_summary values not showing up on checkout success

    If I change this line:
    Code:
     order_id: " <?php echo $order_summary['order_number']; ?>",
    to
    Code:
     order_id: "7",
    the 7 (or whatever random charaacter) shows just fine.... It's just the PHP $order_summary....

    ANy ideas waht I am missing.?

  6. #6
    Join Date
    Nov 2006
    Posts
    56
    Plugin Contributions
    0

    Default Re: $order_summary values not showing up on checkout success

    Zen Cart v1.5.5d

    I coudl try print_r or even var_dump the $order_summary variable, but that requires an order and I was just hoping to avoid having too many extra orders to cancel.


  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: $order_summary values not showing up on checkout success

    Are you "refreshing the page"? or are you using Chrome, which implicitly refreshes the page when showing Page Source in another tab?

    The $order_summary data is intended to output only once: the first time the customer hits that page, so that it doesn't send multiple notices to external services. You wouldn't want to pay commissions to affiliates if the customer sat there refreshing the Success page 20 times, to rack up your payments due. (Ya, I know, "they" should ignore duplicates. Many do. Some don't.)

    Instead of refreshing the page, right-click and use the Inspector. The output this generates is part of the <body> (not the <head>) section.


    FWIW I used your code on a test site here and it works fine: I got all the order summary data properly.

    One caveat: Depending on your PHP version, you probably wanna get in the habit of ALWAYS using <?php and NEVER just <?
    Using <? is bad practice, and in newer versions of PHP will cause the section to be ignored.
    So, change those 3 occurrences of <? to <?php and you're good to go.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Nov 2006
    Posts
    56
    Plugin Contributions
    0

    Default Re: $order_summary values not showing up on checkout success

    I am using Chrome....

    So, the page loads, then I am using VIEW SOURCE - view source seemed easier since I wanted to find a few different occourences of different JS.

    TO repeat - using VIEW SOURCE would refresh the page and create empty variables where I used $order_summar, but NOT where I used $order->products[$i]

    The $order_summary values were just plain empty.

    But the $order->products[$i] values were filled in in the VEIW SOURCE.

    ???

  9. #9
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: $order_summary values not showing up on checkout success

    Quote Originally Posted by ehdesign View Post
    I am using Chrome....

    So, the page loads, then I am using VIEW SOURCE - view source seemed easier since I wanted to find a few different occourences of different JS.

    TO repeat - using VIEW SOURCE would refresh the page and create empty variables where I used $order_summar, but NOT where I used $order->products[$i]

    The $order_summary values were just plain empty.

    But the $order->products[$i] values were filled in in the VEIW SOURCE.

    ???
    If you follow the code of includes/modules/pages/checkout_success/header_php.php you will see that $data_summary is generated from the $_SESSION. Then after the data is collected, the seesion variable is cleared. Reloading the page (ie using the view source option described above with Chrome) will attempt to assign the values to the now empty session... but... the $order data is regenerated however often the page is loaded/reloaded with an exception that if the customer also somehow makes yet another purchase while the screen is up, then refresh (view source) will likely show the latest data (there are notes in the code about this).

    So... to test/see what you want, you need to either use an alternate means to look at the output, or you need to make the output more readily visible. Pick something.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: $order_summary values not showing up on checkout success

    Quote Originally Posted by ehdesign View Post
    I am using Chrome....

    So, the page loads, then I am using VIEW SOURCE - view source seemed easier since I wanted to find a few different occourences of different JS.

    TO repeat - using VIEW SOURCE would refresh the page and create empty variables where I used $order_summar, but NOT where I used $order->products[$i]

    The $order_summary values were just plain empty.

    But the $order->products[$i] values were filled in in the VEIW SOURCE.

    ???
    Yes. Exactly.
    As mc12345678 explained, the $order_summary data is available only once.

    And in reality, that's never a problem for the customer.

    It's only a pain when doing dev stuff. Not much of an issue if you have an offline copy of the site to test on during development.

    If you really want to change that, you can comment-out the unset($_SESSION['order_summary']) line in includes/modules/pages/checkout_success/header_php.php
    I suggest you put it back to normal before you go live with it in production.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. checkout success page not showing after order confirmation
    By muteyaar in forum General Questions
    Replies: 6
    Last Post: 27 Jan 2017, 09:06 PM
  2. Easy Populate Not Showing Uploads Success
    By jvalich in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 11 Mar 2011, 08:50 AM
  3. Free download link not showing at Checkout Success page
    By Blazetamer in forum General Questions
    Replies: 3
    Last Post: 30 Jul 2008, 06:52 PM
  4. Showing Checkout Success page without making an order
    By swingandmiss in forum General Questions
    Replies: 1
    Last Post: 11 Jan 2008, 08:07 PM
  5. Showing a Dynamic Message on Checkout Success Page
    By samad64 in forum General Questions
    Replies: 1
    Last Post: 10 Jul 2007, 06:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR