Jump to content


  • Content count

  • Joined

  • Last visited

Everything posted by jonyo

  1. G, Did you install the "27 Jan 2005 - PayPal IPN Update" update from the contribute section for ccgv? contrib page here. I have installed that update, and am using paypal IPN, and in my tests it skips the paypal step when completely paid for. Although, I do have some heavy modification to the layout of the payment screen (as shown below) but that should not affect how it works. To anyone wanting to make the payment screen a little more easy to understand (at least in my humble opinion): this is how my payment screen now looks: payment screencap And yes I do know that I neglected to customize the stupid redeem button to look like the rest... putting that off in case I decide to change the button look again... I Changed the javascript so that if the voucher amount covers the whole total, when you click on "$38.65 from Gift Vouchers" it unchecks all the radios, and disables them. Then if you uncheck the gift voucher it enables them again. If the gift voucher does not cover the whole total, then you still have to click on one of the other payment methods, even if you click on the voucher. This makes it pretty hard to screw up for customers (although there will always be the one or two trouble customers that still can't figure it out, oh well) Also, if you couldn't guess, the $37.28 changes to whatever amount is able to be applied to your account, like if you have 10 buck voucher, and the total is over 10, it displays $10.00. This makes it clear to customers exactly what will be discounted for the gift voucher. I also made it so that it unregisteres whether the gift voucher is being applied at the top of this page, because when customers go to the checkout and then decide "oh hey, I don't want to use my gift voucher yet!" if they go back to payment, the gift voucher is already put toward the total and they are unable to undo it. It took way too much digging around to figure out how to do this... if you want to do it here is my code... I had to change more than just one page. Unfortunately I did this VERY late at night while drinking liquid jollyranchers (smirnof twist) so I neglected to make much documentation... I will describe to the best of my memory what I did though. They should be pretty accurate, the most I might miss is forgetting to tell you about some commented out line, or something minor like that. Check later in this thread for follow ups by me, before you make this change (in case later in the future I fix a bug in the instructions) 1. BACKUP THE FILES before you edit them!!!! This is especially important since (like I said above) I might be missing a step or two. If you hose your live shop because of this, it's your own fault for not backing up. 2. catalog/checkout_payment.php search the file for $order_total_modules->process(); This will only be in your code if you customized this page to show order total and all that. Comment this line out, as we will be doing it elsewhere in the file. at the beginning of the file, after this line require('includes/application_top.php'); add if (tep_session_is_registered('cot_gv')) tep_session_unregister('cot_gv'); //added to reset whether a gift voucher is used or not on this order after this code around line 133 or so function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } add this code: <?php if (MODULE_ORDER_TOTAL_INSTALLED) $temp=$order_total_modules->process(); $gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'"); $gv_result = tep_db_fetch_array($gv_query); //$temp=$order_total_modules->process(); $temp=$temp[count($temp)-1]; $temp=$temp['value']; if ($gv_result['amount']>=$temp){ $coversAll=true; ?> function clearRadeos(){ document.forms[0].cot_gv.checked=!document.forms[0].cot_gv.checked; for (counter = 0; counter < document.forms[0].payment.length; counter++) { // If a radio button has been selected it will return true // (If not it will return false) if (document.forms[0].cot_gv.checked){ document.forms[0].payment[counter].checked = false; document.forms[0].payment[counter].disabled=true;[CODE] //document.forms[0].cot_gv.checked=false; } else { document.forms[0].payment[counter].disabled=false; //document.forms[0].cot_gv.checked=true; } } }<? } else { $coversAll=false;?> function clearRadeos(){ document.forms[0].cot_gv.checked=!document.forms[0].cot_gv.checked; }<? } ?> On the next line, change the code <?php echo $payment_modules->javascript_validation(); ?> to this (note the $coversAll) (also note that we will be changing the function later on to accept this variable input) <?php echo $payment_modules->javascript_validation($coversAll); ?> At this point I added the checkout info at the top of the screen, you can add this if you want but it's not part of this mod. See my full source below if you want to add it. I got it from another thread somewhere. RIGHT after this code (don't know the line number because of customization) it is at the end of the for loop that draws all the radios for payment selection. </table></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php } ?> </table></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <?php $radio_buttons++; } Add this code: if (tep_session_is_registered('customer_id')) { if ($temp>0){ echo ' <tr><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td><td colspan=2><table border="0" cellpadding="2" cellspacing="0" width="100%"><tr class="moduleRow" onmouseover="rowOverEffect(this)" onclick="clearRadeos()" onmouseout="rowOutEffect(this)" >' . "\n" . ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td><td class="main"><b>'; if ($gv_result['amount']>$temp) echo $currencies->format($temp).' '; else echo $currencies->format($gv_result['amount']).' '; echo $order_total_modules->sub_credit_selection(); } } That should be all I edited on checkout_payment.php, for this mod. See the very end of this post on a bunus of how to get the order total on this page... 3. Edit catalog/includes/classes/order_total.php right before the function credit_selection () add the following function: function sub_credit_selection(){ $selection_string = ''; $close_string = ''; $credit_class_string = ''; if (MODULE_ORDER_TOTAL_INSTALLED) { reset($this->modules); $output_string = ''; while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) { $use_credit_string = $GLOBALS[$class]->use_credit_amount(); if ($selection_string =='') $selection_string = $GLOBALS[$class]->credit_selection(); if ( ($use_credit_string !='' ) || ($selection_string != '') ) { $output_string = /*' <tr><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td><td colspan=2><table border="0" cellpadding="2" cellspacing="0" width="100%"><tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" >' . "\n" . ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' .*/ $use_credit_string; $output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>'; $output_string .= ' </tr></table></td><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td></tr>' . "\n"; //$output_string.=$GLOBALS[$class]->use_credit_amount(); //$output_string .= $selection_string; } } } if ($output_string != '') { //$output_string = $output_string; //$output_string .= $close_string; } } return $output_string; } Change the function credit_selection() to this (sorry, I can't remember what exactly what I edited in the code, but I did edit this function some to not display stuff we alread displayed) function credit_selection() { $selection_string = ''; $close_string = ''; $credit_class_string = ''; if (MODULE_ORDER_TOTAL_INSTALLED) { $header_string = '<tr>' . "\n"; $header_string .= ' <td><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n"; $output1_string .= ' <tr>' . "\n"; $header_string .= ' <td class="main"><b>' . TABLE_HEADING_CREDIT . '</b></td>' . "\n"; $header_string .= ' </tr>' . "\n"; $header_string .= ' </table></td>' . "\n"; $header_string .= ' </tr>' . "\n"; $header_string .= '<tr>' . "\n"; $header_string .= ' <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">' . "\n"; $header_string .= ' <tr class="infoBoxContents"><td><table border="0" width="100%" cellspacing="0" cellpadding="2">' ."\n"; $header_string .= ' <tr><td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . "\n"; $header_string .= ' <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n"; $close_string = ' </table></td>'; $close_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>'; $close_string .= '</tr></table></td></tr></table></td>'; $close_string .= '<tr><td width="100%">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>'; reset($this->modules); $output_string = ''; while (list(, $value) = each($this->modules)) { $class = substr($value, 0, strrpos($value, '.')); if ($GLOBALS[$class]->enabled && $GLOBALS[$class]->credit_class) { //$use_credit_string = $GLOBALS[$class]->use_credit_amount(); if ($selection_string =='') $selection_string = $GLOBALS[$class]->credit_selection(); if ( ($use_credit_string !='' ) || ($selection_string != '') ) { $output_string .= '<tr colspan="4"><td colspan="4" width="100%">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>'; $output_string = ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" >' . "\n" . ' <td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') .'</td>' . ' <td class="main"><b>' . $GLOBALS[$class]->header . '</b></td>' . $use_credit_string; $output_string .= '<td width="10">' . tep_draw_separator('pixel_trans.gif', '10', '1') . '</td>'; $output_string .= ' </tr>' . "\n"; $output_string .= $selection_string; } } } if ($output_string != '') { $output_string = $header_string . $output_string; $output_string .= $close_string; } } return $output_string; } 4. in catalog/includes/modules/order_total/ot_gv.php change the line near the top of the file that STARTS WITH $this->checkbox = $this->user_prompt . '<input type="checkbox" to this $this->checkbox = $this->user_prompt . '<input type="checkbox" onClick="clearRadeos()" name="' . 'c' . $this->code . '">'; find this function: function use_credit_amount() { change it to function use_credit_amount() { global $cot_gv, $currencies; // $_SESSION['cot_gv'] = false; // old code - Strider $cot_gv = false; if ($this->selection_test()) { $output_string = $this->checkbox . '</b>' . '</td>' . "\n";} return $output_string; } (this is needed to bring a few of the tags outside of this function, so that we can put stuff in them that for some reason won't let me add from this function. More specifically, won't let me access the amount of credit that can be applied...) 5. edit file catalog/includes/classes/payment.php line 80 or so: find the line function javascript_validation() { change it to function javascript_validation($coversAll) { A few lines down, find the line if (is_array($this->modules)) { after it add this (heh the only part I rememberd to somewhat comment) //BOF added to check for diff stuff jonyo if ($coversAll) { $addThis='if (document.forms[0].cot_gv.checked) { payment_value=cot_gv; alert (\'hey yo\'); } else '; } else { $addThis=''; } //EOF added to check for diff stuff jonyo after this line ' var payment_value = null;' . "\n" . add this $addThis . //added by jonyo, yo 6. Edit catalog/includes/languages/english/modules/order_total/ot_gv.php (for wordage to sound right) Here is my entire file, since it's pretty small anyways. Change the wording to your liking. The tags (like </td>) that are in the definitions are needed for stuff to line up right, sorry it's a quick and dirty way to do it... <?php /* $Id: ot_gv.php,v 2003/05/14 22:52:59 wilt Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Released under the GNU General Public License */ define('MODULE_ORDER_TOTAL_GV_TITLE', 'Gift Vouchers (-) '); define('MODULE_ORDER_TOTAL_GV_HEADER', 'Enter code below if you have any gift certificates or coupons you have not redeemed yet.'); define('MODULE_ORDER_TOTAL_GV_DESCRIPTION', 'Gift Vouchers'); define('SHIPPING_NOT_INCLUDED', ' [Shipping not included]'); define('TAX_NOT_INCLUDED', ' [Tax not included]'); define('MODULE_ORDER_TOTAL_GV_USER_PROMPT', 'From Gift Vouchers </td><td align=right>'); define('TEXT_ENTER_GV_CODE', 'Enter Redeem Code '); ?> 7. Try it and see what happens. If the instructions work, please post so I know if I put all the steps in. If it doesn't work, or if one of the steps isn't understandable, I'll be happy to help you get it working and post the corrected instructions. BONUS: This is an already posted thing, that I got out of the tips and tricks forum if I remember right. I had to change the table tags a TON from the original to all look right and pretty (at least on my page) Here is the code: in catalog/checkout_payment.php: Around line 218 or so, find the code <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> RIGHT after it, put this snipet: <!--Added by jonyo--> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="main"><b><?php echo HEADING_PRODUCTS; ?></b><? echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php //} for ($i=0, $n=sizeof($order->products); $i<$n; $i++) { echo ' <tr>' . "\n" . ' <td width="10%" class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" . ' <td width="60%" class="main" valign="top">' . $order->products[$i]['name']; if (STOCK_CHECK == 'true') { echo tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty']); } if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) { for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) { echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>'; } } echo '</td>' . "\n"; if (sizeof($order->info['tax_groups']) > 1) echo ' <td class="main" valign="top" align="right">' . tep_display_tax_value($order->products[$i]['tax']) . '% </td>' . "\n"; echo ' <td width="30%"class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . ' </td>' . "\n" . ' </tr>' . "\n"; } ?> <tr> <td COLSPAN="4" valign="top" align="right"> <table border="0" cellspacing="0" cellpadding="3"> <?php if (MODULE_ORDER_TOTAL_INSTALLED) { //$temp=$order_total_modules->process(); echo $order_total_modules->output(); } ?> </table> </td> </tr> </table> </td> </tr> </table></td> </tr> <!-- </table></td> </tr> <!--end added by me--> This bonus is to be treated as an addendum or whatever to the already done tips and tricks thread about adding the cart details and total to the payment_method page. If there are other steps, you will find them there. REMEMBER TO BACK UP!!!
  2. Sorry if this is covered already, I got to page 40 and, well... fell asleep. Sooo... How do I display the discount amount that can be potentially tooken away from the order for a gift voucher? Like what variables/functions/whatever do I need to call to get the amount of gift voucher that can be applied? Also, same question but for how to access the grand total. I tried copying and pasting from the shopping cart info box, but it always thinks both amounts are $0 instead of the right amounts. example: I have in my account a gift voucher for 50 bucks. My order total is only 15 bucks. I want to display it like this... This next part I can set up, but I'll describe it anyways just to put the idea out there: If the gift voucher totally covers the total, make it so that clicking on it will set all of the other payment options to off. If the gift voucher is less than the total, then the person will click on a payment option AND the gift voucher. Like I said I know enough to do that part I just need to be able to access the total and the voucher amount appliable to the order. If and when I get it working I'll post the code so if anyone else wants to set it up this way they can too. The reason I'm changing it is because the current way is very confusing, my test customers say they think they have to enter the voucher code again and hit redeem even when it is already redeemed, so I'm changing it to be a little more self intuitive. Thanks!