Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help With My Script


accelz

Recommended Posts

Help me pls with this one... I cant find any solution so I try to modify some mods from the contribution...

The Pin or Keycode number is delivered in email properly if you buy 1 phonecard product even the quantity is 100 it deliver 100 pin numbers... but if I buy like for example 2 or more different phonecard it only gives me the firrst phonecard product...

 

Example: I have Phonecard$20, Phonecard$30, Phonecard$40.... If I buy 100 Phonecard$20 the pin/serial is deliver succesfully... but If I buy Phonecard$20, Phonecard$30, Phonecard$40 at the same time it only gives the pin/serials of the first Phonecard... can you anyone here help me to fix this :)

 

 

// Phone Card

$newPin = "";

$orders_queryacj = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $customer_id . "' order by date_purchased desc LIMIT 1");

$ordersacj = tep_db_fetch_array($orders_queryacj);

$acjoid = $ordersacj['orders_id'] ;

$products_queryacj = tep_db_query("select * FROM " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . $acjoid . "' ");

$productsacj = tep_db_fetch_array($products_queryacj);

$qty = $productsacj["products_quantity"];

$value = $productsacj["products_price"];

$product_name = $productsacj["products_name"];

$product_id = $productsacj["products_id"];

$phonecard_pin = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_PHONECARD . " WHERE phonecard_name = '" . $product_name . "' AND customers_id = 0 LIMIT 1");

if (tep_db_num_rows($phonecard_pin)) {

for ($q = 0; $q < $qty; $q++) {

//$phonecard_vals = tep_db_fetch_array($phonecard_pin);

$result = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_PHONECARD . " WHERE phonecard_name = '" . $product_name . "' AND customers_id = 0 LIMIT 1");

$numberofkeys = tep_db_num_rows($result)-1;

if ($randomkeycodes == "1") {

// Select a random unused unlock key for this product...

list($usec, $sec) = explode(' ', microtime());

$make_seed = (float) $sec + ((float) $usec * 100000);

mt_srand($make_seed);

$randval = mt_rand(0, $numberofkeys);

$keytext = tep_db_result($result,$randval,"phonecard_pin");

$keyid = tep_db_result($result,$randval,"phonecard_id");

 

} else {

$keytext = tep_db_result($result,$randval,"phonecard_pin");

$keyid = tep_db_result($result,0,"phonecard_id");

 

}

$sql = tep_db_query("UPDATE " . TABLE_PRODUCTS_PHONECARD . " SET customers_id = '" . $customer_id ."', call_nums_issued = now(), orders_id = '" . $acjoid . "' WHERE phonecard_id = '" . $keyid . "'");

$pintext = "You Phone Card Pin Number(s): \n";

if (!$keytext) {

$newPin .= UNLOCKKEY1." $product_name ".UNLOCKKEY2;

}

else

$newPin .= "$product_name : $keytext \n\n";

 

}

 

}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...