Announcement

Collapse
No announcement yet.

Dynamically retrieving values of product variables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Code:
    $sProductLineHTML = '<script type="text/javascript">var mpn = "' . $$pProduct{CUSTOMVARS}{MPN} . '";</script>';
    Is a lot simpler and does what you want (only eyeball tested). Assumes your Variable won't ever contain any double-quote ( " ) characters.

    However, do you really mean

    $sProductLineHTML .=

    Note that dot. Which will add the text to $sProductLineHTML, rather than completely replacing it.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      Norman, you are the man.

      Can I be really cheeky and ask one more question.

      The above mods have now generated the following line, which is brilliant.

      <script type="text/javascript">var mpn = "SLR345";</script>

      My problem now is how to insert this variable into a line of html such as this below?

      <img src='http://test.com/merch/62906/direct;mpn=;ean=;cur=GBP;pr= ;qty=;vendor_name=;prod_name=' height='0' width='0' /></body></html>
      Jonathan

      Comment


        #18
        Sorry, disregard the </body></html> at the end
        Jonathan

        Comment


          #19
          Code:
          <script type="text/javascript">
          document.write("<img src='http://test.com/merch/62906/direct;mpn=;ean=;cur=GBP;yadayada" + mpn + "yadayada />";
          </script>
          For testing leave out the "<" and the text will display on your page so you can debug it. E.g. that URL as you've posted above looks unlikely.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #20
            I am not getting very far with this. Here is what I have done

            I have modified the actinicorder script to write the following in html (which appears on the receipt page)

            <script type="text/javascript">var mpn = "SLR345" var vendor = "TEST1";</script>

            Which is fine.

            At the bottom of the html I have another script as below which I hoped would pull the variables from above in and display the values but instead just shows as below also actinic complains that the variables mpn and vendor are undefined.

            <script type="text/javascript">
            document.write(mpn + vendor)
            </script>
            Jonathan

            Comment


              #21
              Your code:
              Code:
              <script type="text/javascript">var mpn = "SLR345" var vendor = "TEST1";</script>
              Has bugs. No ; between the two statements.

              And it would be good form to end the statement in your second snippet with another semicolon.

              Preview in Firefox and use its Error Console (just hit Control / Shift / J) to see what you're doing wrong next.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #22
                Thanks Norman

                I have modified the scripts and now the first snippet generated shows

                <script type="text/javascript">var mpn = "SLR345"; var vendor = "AV4Home";</script>

                However the second snippet still shows as below without populating the mpn variable

                <script type="text/javascript">
                document.write(mpn);
                </script>

                I have checked the error console and nothing regarding this is mentioned?
                Jonathan

                Comment


                  #23
                  You'll have to inspect the source of the page to see if both bits of code are there and in the correct sequence.

                  As you've not posted a link, no-one here can do it.

                  And, that SD hasn't escaped the HTML and displayed it instead of passing it through unaltered.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment

                  Working...
                  X