We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I have a very small ecommerce script which outputs a price on my checkout page.

    My snippet:
    <?php
    print "<h2>Your cart</h2>";
    
    for($i = 0; $i < count($_POST["id"]); $i++){
    	print $_POST["quantity"][$i]."x " .$_POST["name"][$i].": ".$_POST["price"][$i]."<br/>";
    }
    
    print "<h2>Total cost: ".$_POST["cost"]."</h2>";
    ?>


    http://codecanyon.net/item/jquery-plugin-shopping-cart/350282

    Below this I have a form with eForm.

    The price needs to be added to the eForm email.
    How can I do this?

    Add a (hidden) field and use JS to copy the number in that field?
    Or is there a better (non js) solution possible?
      Evolution user, I like the back-end speed and simplicity smiley
      • 20413
      • 2,877 Posts
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 9995
        • 1,613 Posts
        I doubt that is gona work, the price is not saved into a DB field and no TV.
        It is stored with cookies.
          Evolution user, I like the back-end speed and simplicity smiley
          • 9995
          • 1,613 Posts
          I think I'm gona use something like this shocked

          http://jsfiddle.net/3rXjx/
            Evolution user, I like the back-end speed and simplicity smiley
            • 20413
            • 2,877 Posts
            Quote from: fourroses666 at Jun 10, 2014, 04:33 AM
            I doubt that is gona work, the price is not saved into a DB field and no TV.
            It is stored with cookies.

            I'll show you how you would modify the code when I have some time to spare. No need using tv's or database...
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 9995
              • 1,613 Posts
              okidokie smiley
                Evolution user, I like the back-end speed and simplicity smiley
                • 20413
                • 2,877 Posts
                Try this (not tested)

                customPlaceholderSnippet
                //<?php
                if( !function_exists('customPlaceholder') ){
                   function customPlaceholder(&$fields,&$templates){
                      $cost = preg_replace('#[^0-9\.]#', '', $_POST["cost"]);
                      $templates['report'] = str_replace('[+cost+]',$cost,$templates['report']);
                      return true;
                   }
                }
                


                Add [+cost+] placeholder to your report-tpl.

                [[customPlaceholderSnippet]]
                [!eForm? &eFormOnBeforeFormParse=`customPlaceholder` ...all your other params...!]


                If it works, you're welcome.

                // This is how you'd send a whole ditto call: https://forums.modx.com/thread/47218/dynamic-form-fields-and-dynamic-report-is-it-posible-yes-it-is#dis-post-273520 [ed. note: mrhaw last edited this post 12 years, 3 months ago.]
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 13428 ☆ A M B ☆
                  • 1,031 Posts
                  https://github.com/Jako/phxeform could be an option too.
                    • 20413
                    • 2,877 Posts
                    Quote from: Jako at Jun 10, 2014, 11:25 AM
                    https://github.com/Jako/phxeform could be an option too.

                    +1 smiley Jako -->
                    ZZO???++++===========================~======+++?II$7I$ZO8$$7
                    ZZZ?I???++++++=====+=======================+++=??II$$$7$$Z$$
                    ZZZ?III??++++=====+======~==~~~~============~====??II7$777$7
                    Z$ZIII???++++====+=====~~~~~~~~~==========+=+===+++?II77$777
                    $$Z7III??+======+====~~~~~~~~~~~~~~~~~~===++======+??I7II7II
                    $$Z$III?++===~============~~~~~~~::~~==============+IIII777?
                    $ZZZIII??++++=====+========~~~~:~:~~====+=+=========+??I7I7?
                    $ZZOZI????+?+++=+++++++==~~==+++++=++====+===+======+?III7??
                    $$ZOO?+??+++??+?++I???+++I7Z8Z$7II????III?+=+======++?IIII?+
                    $ZZOO++++++++???++?7I7$Z8DD8O$$$$$ZZZ$Z$$7$+?+++++++++II???+
                    ZZZOO+++I77$Z$$77I?+7OOO8OONMDZDMMNDDDDDOZ$?==+++?++++???+?+
                    $ZZZ$II$ODNNND888ZI?+IZ8D8DMDO777I?II???+==~===+==++++????+?
                    $$$ZZ7$$7$ONMMMMMM?=~~?ZOOZOZ7III7II?++~=~~=====++++++????++
                    $$ZZZZ778MNO8DOODNI=~=++?IIZZZZZZZ$+==~~~~=~===++++++?????++
                    $$$$ZZZ7Z8$$$$ZO88+=~=+====~~==+++~=~~~~~=~===+++++??????+++
                    $$$ZZZO$$8$$ZOODZ?+~~===+===~==~~~~~~~~~~~~~==+++??I??I???++
                    $ZZZOO8DI7$$Z$$I+?+:~=++======~====~~~~~~====++++???++??+??+
                    ZZZZO88DII?++++++?=:=++===+++++++++=========+?+++??????+????
                    ZZZOOO8D7??+===+++~===++===+?I7I++++++=+=+=+=+++++++?????+?+
                    ZZZOOO888+++++++?+~~==+=====+IIIZ$I?????++++++=++++++??????I
                    ZZZOOOO88?+++++?I+=~~====++?7$+++IO$$7III??????I?++++??????I
                    OOZOZZO887++??I7I++=~=?I7ZO8O~++=++IZ8$7II?????II++++????II?
                    OOOOOOOO88????I7$?IIIZOMMDDZ?++=+=?+??+IZ7I??I?I??+??+?I????
                    OOOZZZOO88ZII77$Z?O8D88DDD8II????==?+??+++???I??I?++?+??I???
                    OZZZZZZOO88$$$ZZ7?+$ODNNNNZ7I???+?=?I?III???????I?????+III7$
                    ZZZZZZZOOODD7$Z7I++$ODDMM8$77II??II$Z8Z$II+?????I????II777$$
                    ZZZZZZZZOO8D87$I??+$Z8OOZII7II$$$ODMM8O$7?+??I?II?II??77$$$O
                    ZZZZZZZZOO8DD87II7?Z8Z8DNNMDZI++I?=+++???I??II?II?I??II77$Z8
                    ZZZZZZZOOO8DDDO777ODNMDZ7++++=++?+++===+?I7II7II?II77$7$ZZDO
                    ZZZZZZZZOOO8DDN$$I$ZOO7$77I7II?+?+?==++??I?I7II77?777Z$$OO8O
                    OZOOOOOZZOO88DDD$777Z$77I?I7I+II+++=++????+II7II??7777ZZZZZO
                    OOOOOZZZZZZOO8DD8Z$$$$$7I7I7$7II??=+?++?+??I+I777I$IZ$ZO$OOZ
                    OZZZZOZZZZZZZOO8888$$Z$$I$7I7?I+??????I?????II7777$$I$Z$O8OZ
                    ZZZOZZZZZZZZZOO88888OOZ7II7I7+++++++???+?=??II$77ZZ7Z$ZODOZZ
                    OZZOOZZZZZZZZZOOO8888OZ77I??II?++??II??++?I77$$7$$$$$Z88OOZ$
                    ZZZZOZZZZZZZZZZZOO88DDOZ$777I7???I????++?I$IO88ZZ$ZZZO888O$7
                    ZZZZOOZZZ$$$$$$ZZZOOO888Z7??II???7??+III7$8D88OOZZZZ8OD8O$7I
                    $ZZZZZ$$$$$$$77$$$ZZZOZOZZ$7777???+7$$$ZOZ8O8ZOOZZOOODOZ$7I?
                                                                 GlassGiant.com 
                    
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                      • 9995
                      • 1,613 Posts
                      Hmm, can't get it to work your customplaceholder snippet sad empty output.
                      Don't forget I'm not a coder. I really don't get it. The price is shown by some javascript and cookies and not a tv.

                      Also Jako's phxeform code I don't get. Because I don't have a [*cost*] tv so what do I need to grab?

                      Is this a solution maybe?
                      Add my (stripped) snippet into the eform tpl and add it like this:

                      Stripped snippet: (my-stripped-snip)
                      <?php print $_POST["cost"]; ?>


                      and eForm:
                      <input type='hidden' name="cost" value='[[my-stripped-snip]]' ?>' ... />


                      and in my report: [+cost+] ?

                      I will try this lipsrsealed [ed. note: fourroses666 last edited this post 12 years, 3 months ago.]
                        Evolution user, I like the back-end speed and simplicity smiley