mjpwall Posted December 4, 2007 Posted December 4, 2007 Hi, I need to pass the order total and id to javascript, but haven't a clue how to do it, I really need this implemented for a client asap and am new to os commerce. I really need help with this and would be very grateful for any assistance.
photofxplus Posted December 4, 2007 Posted December 4, 2007 That would be fun.. All I can think of is to create a hidden value in a form, then retireve it as a "POST" variable via javascript. You would just write the form using php such as.. <? php echo tep_draw_form('my_form_name', '', $method = 'post') . tep_draw_hidden_field('order_id', $HTTP_GET_VAR['order_id']) . '<form>'; ?> The varibales you need may already be passed as POST variables depending on which page you are looking at.. Bottom line is, you CAN retrieve POST values via javascript.. maybe GET as well... its a place to start anyway. Sorry but its been a while since Ive worked with javascript. Lloyd
mjpwall Posted December 4, 2007 Author Posted December 4, 2007 Excellent thanks that's a great start. I'll try it.
mjpwall Posted December 4, 2007 Author Posted December 4, 2007 Ok i'll be honest I have no idea how to do this, the code I need to implement is as follows: <script Language="JavaScript"> <!--//Begin var winName = top.window.name; var winNameArray = winName.split("_"); var MemberID = winNameArray[1]; var OfferID = winNameArray[2]; var transaction_value = 'WRITE_OUT_VALUE_OF_TRANSACTION_HERE'; var unique_identifier = 'WRITE_OUT_UNIQUE_IDENTIFIER_HERE'; if (top.window.name.substring(0,17)=="PigsBackMemberID_") { document.write('<img src="https://www.pigsback.com/pb/callback.asp?mid='+MemberID+'&oid='+OfferID+'&desc='+transaction_value+'&uid='+unique_identifier+'" width="1" height="1">'); } //--> </Script> I need to use it in checkout_success.php to retrieve an order-id and an order_total if you could help that would be fantastic
photofxplus Posted December 4, 2007 Posted December 4, 2007 Try something like: var transaction_value = <?php echo HTTP_GET_VAR['order total']; ?>; var unique_identifier = <?php echo HTTP_GET_VAR['order_id']; ?>; or substitute GET variables with POST variables retrieved from form. Lloyd
photofxplus Posted December 4, 2007 Posted December 4, 2007 One other thing, I was wrong about retrieving POST variables via javascript. Cant be done -- sorry. Have to try and write them into code as page loads, thats what the code above attempts to do. Lloyd
sonictrip.net Posted May 31, 2010 Posted May 31, 2010 One other thing, I was wrong about retrieving POST variables via javascript. Cant be done -- sorry. Have to try and write them into code as page loads, thats what the code above attempts to do. Has anyone figured this code out yet? I also need to use it for a client... thanks.
sonictrip.net Posted June 5, 2010 Posted June 5, 2010 SOLUTION: STEP 1 Add the following code to checkout_process.php above the line:- "// send emails to other people". $OrderTotal = $currencies->format($cart->show_total() - $total_tax); tep_session_register('OrderTotal'); STEP 2 Add the following code within the <script> part of checkout_success.php where you have the rest of your javascript: var transaction_value = "<?php echo $OrderTotal; ?>"; var unique_identifier = "<?php echo $order_id; ?>";
Recommended Posts
Archived
This topic is now archived and is closed to further replies.