Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Run a script after confirming credit card


Guest

Recommended Posts

Posted

I have an installation of OSC and would like to use it to grant access to specialized training material on my web site. The idea is that users order and pay for the training course and when the credit card transaction is confirmed access is granted to the material.

 

I think what I am looking for is similar to the product download currently available in OSC. All I need is a way to run an SQL script to grant access after the credit card transaction is completed.

 

Anyone know of something like this?

 

Cheers.

Posted

I did a little hack to get this to work. While I am using a slightly modified version of OSC that has been converted into a Geeklog plugin it should work the same on the latest version of OSC.

 

This is the original section of code in checkout_success.php that needs modification.

<?php
 if ($global['global_product_notifications'] != '1') {
   echo TEXT_NOTIFY_PRODUCTS . '<br><p class="productsNotifications">';

   $products_displayed = array();
   for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {
     if (!in_array($products_array[$i]['id'], $products_displayed)) {
       echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';
       $products_displayed[] = $products_array[$i]['id'];
     }
   }

   echo '</p>';
 } else {
   echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;
 }
?>

 

 

 

This is the modified section of code.

I don't need the product notification so I commented it out. Then I run the sql to add information to a table granting this user access to the training material. Finally I print that access has been granted to each training module purchased. I still need to add error checking but you get the idea.

<?php
 if ($global['global_product_notifications'] != '1') {
   echo TEXT_NOTIFY_PRODUCTS . '<br><p class="productsNotifications">';

   $products_displayed = array();
   for ($i=0, $n=sizeof($products_array); $i<$n; $i++) {
     if (!in_array($products_array[$i]['id'], $products_displayed)) {

//	GTG - Dont show the checkboxes - Don't need the notification
//        echo tep_draw_checkbox_field('notify[]', $products_array[$i]['id']) . ' ' . $products_array[$i]['text'] . '<br>';
       $products_displayed[] = $products_array[$i]['id'];

//	GTG - Add the modules purchased sql here 

$rightnow = date('Y-m-d H:i:s');
$sql_addit = "INSERT INTO `gl_Train_ModulesPurchased` ( `CustomerID` , `ModuleID` , `Created` ) 
 VALUES ('{$customer_id}', '{$products_array[$i]['id']}', '{$rightnow}');";
$result_addit = mysql_query($sql_addit);


Echo 'Granted Access to - ' . $products_array[$i]['text'];
Echo "<br>";

      
     }
   }

   echo '</p>';
 } else {
   echo TEXT_SEE_ORDERS . '<br><br>' . TEXT_CONTACT_STORE_OWNER;
 }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...