chrometweaks.org

Where can I find a free or cheap iPage web host?

Click Here To View All Answers...


Quick question... Where can I find a free or cheap iPage web host? Thanks in advance for any answer. Another quick question... A simple thing, however I have been going dizzy on this one..

Where line 326 is the bottom..

<?php.

/*.

 $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $.

 osCommerce, Open Source E-Commerce Solutions.

 http://www.oscommerce.com.

 Copyright (c) 2003 osCommerce.

 Released under the GNU General Public License.

  Updated for: Authorize.net Consolidated v1.5.

  Date: March 24, 2004.

  Changes: Rewrote many of the customer info fields, also the order id is now inserted.

           into the database before it goes to processing so Authorize.net Consolidated.

           has an order ID to send to Authorize.net.  However this means that failed orders.

 will also have an order ID..

  Author: Austin Renfroe (Austin519).

  Email:.

*/.

 include('includes/application_top.php');.

// if the customer is not logged on, redirect them to the login page.

 if (!tep_session_is_registered('customer_id')) {.

   $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));.

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));.

 }.

 .

 if (!tep_session_is_registered('sendto')) {.

   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));.

 }.

 if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {.

   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));.

}.

// avoid hack attempts during the checkout procedure by checking the internal cartID.

 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {.

   if ($cart->cartID != $cartID) {.

     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));.

   }.

 }.

 include(DIR_WS_LANGUAGES$language'/'FILENAME_CHECKOUT_PROCESS);.

// load selected payment module.

 require(DIR_WS_CLASSES'payment.php');.

 if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS.

 $payment_modules = new payment($payment);.

 // Need to be included before Authorizenet ADC Direct Connection.

// load the selected shipping module.

 require(DIR_WS_CLASSES'shipping.php');.

 $shipping_modules = new shipping($shipping);.

 require(DIR_WS_CLASSES'order.php');.

 $order = new order;.

// load the before_process function from the payment modules.

 $payment_modules->before_process();.

//************************************************************.

// Authorizenet ADC Direct Connection.

//************************************************************.

 require(DIR_WS_CLASSES'order_total.php');.

 $order_total_modules = new order_total;.

 $order_totals = $order_total_modules->process();.

 $sql_data_array = array('customers_id' => $customer_id,.

                         'customers_name' => $order->customer['firstname']' '$order->customer['lastname'],.

                         'customers_company' => $order->customer['company'],.

                         'customers_street_address' => $order->customer['street_address'],.

                         'customers_suburb' => $order->customer['suburb'],.

                         'customers_city' => $order->customer['city'],.

                         'customers_postcode' => $order->customer['postcode'],.

                         'customers_state' => $order->customer['state'],.

                         'customers_country' => $order->customer['country']['title'],.

                         'customers_telephone' => $order->customer['telephone'],.

                         'customers_email_address' => $order->customer['email_address'],.

                         'customers_address_format_id' => $order->customer['format_id'],.

                         'delivery_name' => $order->delivery['firstname']' '$order->delivery['lastname'],.

                         'delivery_company' => $order->delivery['company'],.

                         'delivery_street_address' => $order->delivery['street_address'],.

                         'delivery_suburb' => $order->delivery['suburb'],.

                         'delivery_city' => $order->delivery['city'],.

                         'delivery_postcode' => $order->delivery['postcode'],.

                         'delivery_state' => $order->delivery['state'],.

                         'delivery_country' => $order->delivery['country']['title'],.

                         'delivery_address_format_id' => $order->delivery['format_id'],.

                         'billing_name' => $order->billing['firstname']' '$order->billing['lastname'],.

                         'billing_company' => $order->billing['company'],.

    'billing_street_address' => $order->billing['street_address'],.

                         'billing_suburb' => $order->billing['suburb'],.

                         'billing_city' => $order->billing['city'],.

                         'billing_postcode' => $order->billing['postcode'],.

                         'billing_state' => $order->billing['state'],.

                         'billing_country' => $order->billing['country']['title'],.

                         'billing_address_format_id' => $order->billing['format_id'],.

                         'payment_method' => $order->info['payment_method'],.

                         'cc_type' => $order->info['cc_type'],.

                         'cc_/img/avatar3.jpg' => $order->info['cc_/img/avatar3.jpg'],.

                         'cc_number' => $order->info['cc_number'],.

                         'cc_expires' => $order->info['cc_expires'],.

                         'date_purchased' => 'now()',.

//                          'orders_status' => DEFAULT_ORDERS_STATUS_ID,.

                         'orders_status' => $order->info['order_status'],.

   // the following field has been moved from orders to order_status_history.

   // 'comments' => $order->info['comments'],.

                         'currency' => $order->info['currency'],.

                         'currency_value' => $order->info['currency_value']);.

 tep_db_perform(TABLE_ORDERS, $sql_data_array);.

 $insert_id = tep_db_insert_id();.

// Make sure the /catalog/includes/class/order.php is included.

// and $order object is created before this!!!.

If(MODULE_PAYMENT_AUTHORIZENET_STATUS) {.

 include(DIR_WS_MODULES'authorizenet_direct.php');.

}.

//************************************************************.

// load the before_process function from the payment modules.

 $payment_modules->before_process();.

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {.

   $sql_data_array = array('orders_id' => $insert_id,.

                           'title' => $order_totals[$i]['title'],.

                           'text' => $order_totals[$i]['text'],.

                           'value' => $order_totals[$i]['value'],.

                           'class' => $order_totals[$i]['code'],.

                           'sort_order' => $order_totals[$i]['sort_order']);.

   tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);.

 }.

//the following lines were changed for the MS1 and snapshots after 2003-02-17 db structure.

 $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';.

 $sql_data_array = array('orders_id' => $insert_id,.

//                          'orders_status_id' => DEFAULT_ORDERS_STATUS_ID,.

                         'orders_status_id' => $order->info['order_status'],.

                         'date_added' => 'now()',.

                         'customer_notified' => $customer_notification,.

       'comments' => $order->info['comments']);.

 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);.

//end update to MS1.

// initialized for the email confirmation.

 $products_ordered = '';.

 $subtotal = 0;.

 $total_tax = 0;.

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {.

// Stock Update - Joao Correia.

   if (STOCK_LIMITED == 'true') {.

     if (DOWNLOAD_ENABLED == 'true') {.

       $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename.

                           FROM "TABLE_PRODUCTS" p.

                           LEFT JOIN "TABLE_PRODUCTS_ATTRIBUTES" pa.

                            ON p.products_id=pa.products_id.

                           LEFT JOIN "TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD" pad.

                            ON pa.products_attributes_id=pad.products_attributes_id.

                           WHERE p.products_id = '"tep_get_prid($order->products[$i]['id'])"'";.

// Will work with only one option for downloadable products.

// otherwise, we have to build the query dynamically with a loop.

       $products_attributes = $order->products[$i]['attributes'];.

       if (is_array($products_attributes)) {.

         $stock_query_raw .= " AND pa.options_id = '"$products_attributes[$i]['option_id']"' AND pa.options_values_id = '"$products_attributes[$i]['value_id']"'";.

       }.

       $stock_query = tep_db_query($stock_query_raw);.

     } else {.

       $stock_query = tep_db_query("select products_quantity from "TABLE_PRODUCTS" where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

     }.

     if (tep_db_num_rows($stock_query) > 0) {.

     $stock_values = tep_db_fetch_array($stock_query);.

// do not decrement quantities if products_attributes_filename exists.

     if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {.

       $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];.

     } else {.

       $stock_left = $stock_values['products_quantity'];.

     }.

     tep_db_query("update "TABLE_PRODUCTS" set products_quantity = '"$stock_left"' where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

       if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {.

       tep_db_query("update "TABLE_PRODUCTS" set products_status = '0' where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

       }.

     }.

   }.

// Update products_ordered (for bestsellers list).

   tep_db_query("update "TABLE_PRODUCTS" set products_ordered = products_ordered + "sprintf('%d', $order->products[$i]['qty'])" where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

   $sql_data_array = array('orders_id' => $insert_id,.

                           'products_id' => tep_get_prid($order->products[$i]['id']),.

                           'products_model' => $order->products[$i]['model'],.

                           'products_name' => $order->products[$i]['name'],.

                           'products_price' => $order->products[$i]['price'],.

                           'final_price' => $order->products[$i]['final_price'],.

                           'products_tax' => $order->products[$i]['tax'],.

                           'products_quantity' => $order->products[$i]['qty']);.

   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);.

   $order_products_id = tep_db_insert_id();.

   $order_total_modules->update_credit_account($i);//ICW ADDED FOR CREDIT CLASS SYSTEM.

//insert customer choosen option to order.

   $attributes_exist = '0';.

   $products_ordered_attributes = '';.

   if (isset($order->products[$i]['attributes'])) {.

     $attributes_exist = '1';.

     for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {.

       if (DOWNLOAD_ENABLED == 'true') {.

         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename.

                              from "TABLE_PRODUCTS_OPTIONS" popt, "TABLE_PRODUCTS_OPTIONS_VALUES" poval, "TABLE_PRODUCTS_ATTRIBUTES" pa.

                              left join "TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD" pad.

                               on pa.products_attributes_id=pad.products_attributes_id.

                              where pa.products_id = '"$order->products[$i]['id']"'.

                               and pa.options_id = '"$order->products[$i]['attributes'][$j]['option_id']"'.

                               and pa.options_id = popt.products_options_id.

                               and pa.options_values_id = '"$order->products[$i]['attributes'][$j]['value_id']"'.

                               and pa.options_values_id = poval.products_options_values_id.

                               and popt.language_id = '"$languages_id"'.

                               and poval.language_id = '"$languages_id"'";.

         $attributes = tep_db_query($attributes_query);.

       } else {.

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from "TABLE_PRODUCTS_OPTIONS" popt, "TABLE_PRODUCTS_OPTIONS_VALUES" poval, "TABLE_PRODUCTS_ATTRIBUTES" pa where pa.products_id = '"$order->products[$i]['id']"' and pa.options_id = '"$order->products[$i]['attributes'][$j]['option_id']"' and pa.options_id = popt.products_options_id and pa.options_values_id = '"$order->products[$i]['attributes'][$j]['value_id']"' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '"$languages_id"' and poval.language_id = '"$languages_id"'");.

       }.

       $attributes_values = tep_db_fetch_array($attributes);.

       $sql_data_array = array('orders_id' => $insert_id,.

                               'orders_products_id' => $order_products_id,.

                               'products_options' => $attributes_values['products_options_name'],.

                               'products_options_values' => $order->products[$i]['attributes'][$j]['value'],.

                               'options_values_price' => $attributes_values['options_values_price'],.

                               'price_prefix' => $attributes_values['price_prefix']);.

       tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);.

       if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {.

         $sql_data_array = array('orders_id' => $insert_id,.

                                 'orders_products_id' => $order_products_id,.

                                 'orders_products_filename' => $attributes_values['products_attributes_filename'],.

                                 'download_maxdays' => $attributes_values['products_attributes_maxdays'],.

                                 'download_count' => $attributes_values['products_attributes_maxcount']);.

         tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);.

       }.

   //clr 030714 changing to use values from $orders->products and adding call to tep_decode_specialchars().

       $products_ordered_attributes .= "\n\t"$attributes_values['products_options_name']' 'tep_decode_specialchars($order->products[$i]['attributes'][$j]['value']);.

     //$products_ordered_attributes .= "\n\t"$attributes_values['products_options_name']' '$attributes_values['products_options_values_name'];.

     }.

   }.

//insert customer choosen option eof.

   $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);.

   $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];.

   $total_cost += $total_products_price;.

   $products_ordered .= $order->products[$i]['qty']' x '$order->products[$i]['name']' ('$order->products[$i]['model']') = '$currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty'])$products_ordered_attributes"\n";.

 }.

$order_total_modules->apply_credit();//ICW ADDED FOR CREDIT CLASS SYSTEM.

// lets start with the email confirmation.

If (!tep_session_is_registered('noaccount')).

{.

 $email_order = STORE_NAME"\n".

                EMAIL_SEPARATOR"\n".

                EMAIL_TEXT_ORDER_NUMBER' '$insert_id"\n" ..

                EMAIL_TEXT_INVOICE_URL' 'tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id='$insert_id, 'SSL', false)"\n" ..

                EMAIL_TEXT_DATE_ORDERED' 'strftime(DATE_FORMAT_LONG)"\n\n";.

 if ($order->info['comments']).

 {.

   $email_order .= tep_db_output($order->info['comments'])"\n\n";.

 }.

 $email_order .= EMAIL_TEXT_PRODUCTS"\n".

                 EMAIL_SEPARATOR"\n".

                 $products_ordered.

                 EMAIL_SEPARATOR"\n";.

} else {.

 $email_order = STORE_NAME"\n".

                EMAIL_SEPARATOR"\n".

                EMAIL_TEXT_ORDER_NUMBER' '$insert_id"\n" ..

                EMAIL_TEXT_DATE_ORDERED' 'strftime(DATE_FORMAT_LONG)"\n\n";.

 if ($order->info['comments']) {.

   $email_order .= $order->info['comments']"\n\n";.

 }.

 $email_order .= EMAIL_TEXT_PRODUCTS"\n".

                 EMAIL_SEPARATOR"\n".

                 $products_ordered.

                 EMAIL_SEPARATOR"\n";.

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {.

   $email_order .= strip_tags($order_totals[$i]['title'])' 'strip_tags($order_totals[$i]['text'])"\n";.

 }.

 if ($order->content_type != 'virtual') {.

 $email_order .= "\n"EMAIL_TEXT_DELIVERY_ADDRESS"\n".

                 EMAIL_SEPARATOR"\n" ..

                 tep_address_label($customer_id, $sendto, 0, '', "\n")"\n\n" ..

                 EMAIL_TEXT_BILLING_ADDRESS"\n" ..

 }  // edited, possible missing closing tag.

 $email_order .= "\n"EMAIL_TEXT_BILLING_ADDRESS"\n" ..

                 EMAIL_SEPARATOR"\n" ..

                 tep_address_label($customer_id, $billto, 0, '', "\n")"\n\n";.

 if (is_object($$payment)) {.

   $email_order .= EMAIL_TEXT_PAYMENT_METHOD"\n".

                   EMAIL_SEPARATOR"\n";.

   $payment_class = $$payment;.

   $email_order .= $payment_class->title"\n\n";.

   if ($payment_class->email_footer) {.

     $email_order .= $payment_class->email_footer"\n\n";.

   }.

 }.

 tep_mail($order->customer['firstname']' '$order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_/img/avatar3.jpg, STORE_/img/avatar3.jpg_EMAIL_ADDRESS, '');.

// send emails to other people.

 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {.

   tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_/img/avatar3.jpg, STORE_/img/avatar3.jpg_EMAIL_ADDRESS, '');.

 }.

// load the after_process function from the payment modules.

 $payment_modules->after_process();.

 $cart->reset(TRUE);.

// unregister session variables used during checkout.

 tep_session_unregister('sendto');.

 tep_session_unregister('billto');.

 tep_session_unregister('shipping');.

 tep_session_unregister('payment');.

 tep_session_register('last_order');.

 $last_order = $insert_id;.

 tep_session_unregister('comments');.

If(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');.

 $order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM.

 tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));.

 require(DIR_WS_INCLUDES'application_bottom.php');.

?>..

Comments (12)

I'm stumped. I'm not so sure what is the answer to your question. I'll do some research and get back to you if I discover an answer. You should email the people at iPage as they probably know..

Comment #1

John,.

One more } here?.

'"tep_get_prid($order->products[$i]['id'])"'");.

}.

}.

}.

There are 30 { and 29 }..

This post has been edited by.

GORF.

: 03 October 2004, 16:29..

Comment #2

I could find the closing bracket for this else (at line 273).

} else {.

$email_order = STORE_NAME"\n".

               EMAIL_SEPARATOR"\n".

               EMAIL_TEXT_ORDER_NUMBER' '$insert_id"\n" ..

               EMAIL_TEXT_DATE_ORDERED' 'strftime(DATE_FORMAT_LONG)"\n\n";.

Jack..

Comment #3

$email_order .= EMAIL_TEXT_PRODUCTS"\n".

EMAIL_SEPARATOR"\n".

$products_ordered.

EMAIL_SEPARATOR"\n";.

} else {.

There is a closing brace }.

You may find it beneficial to mark the braces with a comment // Mibble - closes whatever the line that opened the brace.

That is how I sometimes do it, a bit of time initially but gets the result..

Example.

// send emails to other people.

If (SEND_EXTRA_ORDER_EMAILS_TO != '') {.

Tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, nl2br($email_order), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');.

} // Mibble - closes - if (SEND_EXTRA_ORDER_EMAILS_TO != '') {.

This post has been edited by.

241.

: 03 October 2004, 16:43..

Comment #4

Steve - at what line do you see the closing bracket? I've looked again but don't see it..

Jack..

Comment #5

Jack you and I are at the same line, you have the code below and I the code above. I am looking at the closing brace in front of the else but not seeing the openning brace for this..

As I posted it is easier if the code is commented, I have started doing this with contributions that I am working on in order to keep track of this sort of thing and it has helped me resolve a number of issues..

Maybe John can add some comments to the closing braces to help him resolve his issue...

Comment #6

Would you care to ellaborate with a bit more information as Jack and I are at the same line of code..

Comment #7

The closing brace for the else does not exist was what I was trying to convey..

This post has been edited by.

Yesudo.

: 03 October 2004, 17:26..

Comment #8

The opening bracket for the else is at line 259. I just removed everything except the if/else block and it is definitely missing the closing bracket. I agree with you about the commenting though. I do a really bad job of commenting my code most of the time. It is an on-going battle..

Jack..

Comment #9

Yes I concur that it is the closing bracket of the else statement..

Comment #10

Ok thanks guys, I will look at this. finally back from boston, in a wall to wall crowd of people sampling food at fenway park..

Comment #11

Hey... can I get in on this useful help? I've got the same error, same page, and it happened right after I installed the 5.1 gift voucher. I can't seem to apply your solution to mine, though. Perhaps I have a different fluke. Help?.

<?php.

/*.

 $Id: checkout_process.php,v 1.2.37.2 2004/01/01 14:00:29 Strider Exp $.

 $Id: checkout_process.php,v 1.128 2003/07/24 18:00:29 Strider Exp $.

 $Id: checkout_process.php,v 1.128 2003/05/28 18:00:29 hpdl Exp $.

 $Id: checkout_process.php,v 1.6.2.1 2003/05/03 23:41:23 wilt Exp $.

 osCommerce, Open Source E-Commerce Solutions.

 http://www.oscommerce.com.

 Copyright (c) 2003 osCommerce.

 Released under the GNU General Public License.

*/.

 include('includes/application_top.php');.

 if (getenv('HTTP_X_FORWARDED_FOR')) {.

     $ip=getenv('HTTP_X_FORWARDED_FOR');.

 }.

 else {.

     $ip=getenv('REMOTE_ADDR');.

 }.

// if the customer is not logged on, redirect them to the login page.

 if (!tep_session_is_registered('customer_id')) {.

   $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));.

   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));.

 }.

 .

 if (!tep_session_is_registered('sendto')) {.

   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));.

 }.

 if ( (tep_not_null(MODULE_PAYMENT_INSTALLED)) && (!tep_session_is_registered('payment')) ) {.

   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));.

}.

// avoid hack attempts during the checkout procedure by checking the internal cartID.

 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {.

   if ($cart->cartID != $cartID) {.

     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));.

   }.

 }.

 include(DIR_WS_LANGUAGES$language'/'FILENAME_CHECKOUT_PROCESS);.

// load selected payment module.

 require(DIR_WS_CLASSES'payment.php');.

 if ($credit_covers) $payment=''; //ICW added for CREDIT CLASS.

 $payment_modules = new payment($payment);.

// load the selected shipping module.

 require(DIR_WS_CLASSES'shipping.php');.

 $shipping_modules = new shipping($shipping);.

 require(DIR_WS_CLASSES'order.php');.

 $order = new order;.

// load the before_process function from the payment modules.

 $payment_modules->before_process();.

 require(DIR_WS_CLASSES'order_total.php');.

 $order_total_modules = new order_total;.

 $order_totals = $order_total_modules->process();.

// order is successful processed we can process the referral now.

 if(USE_REFERRAL_SYSTEM == 'true') {.

   if(tep_session_is_registered('customer_referral_referred') && REFERRAL_ACCEPT_METHOD == 'checkout') {.

         tep_add_referral_point($customer_referral_referred);.

 //check all the products if they are still available in the registry. Just to make sure, nobody else ordered them while we have been shopping..

 if($cart->registry_id != '0'){.

//    print('<br>Cart:<br>');.

//    print_r($cart);.

//    print('<br>Order:<br>');.

//    print_r($order);.

   $check_products_query_string = "SELECT registry_products_id, products_id, (registry_products_quantity - registry_products_quantity_received) as registry_available_quantity, final_price FROM "TABLE_REGISTRY_PRODUCTS" WHERE registry_id = '"$cart->registry_id"'";.

   $check_products_query = tep_db_query($check_products_query_string);.

//    print('<br>Check products:<br>');.

   $products_out_of_range = '';.

   $products_not_in_registry = '';.

   for($i = 0; $i < sizeof($order->products); $i++){.

     $product_in_registry = false;.

     mysql_data_seek($check_products_query, 0);.

     while($check_products = tep_db_fetch_array($check_products_query)){.

//print($i': Order product ID '$order->products[$i]['id']', Check registry product ID '$check_products['products_id']', Order quantity '$order->products[$i]['qty']', available quantity '$check_products['registry_available_quantity']'<br>');.

       if(($order->products[$i]['id'] == $check_products['products_id']) && ($order->products[$i]['qty'] > $check_products['registry_available_quantity'])){.

         $products_out_of_range[] = $check_products['products_id'];.

         $product_in_registry = true;.

//print('BREAK<br>');.

         break;.

       }elseif($order->products[$i]['id'] == $check_products['products_id']){.

         $order->products[$i]['registry_products_id'] = $check_products['registry_products_id'];.

         $order->products[$i]['registry_products_customers_id'] = $cart->registry_customers_id;.

         $product_in_registry = true;.

//print('BREAK<br>');.

         break;.

       }.

     } // end while.

     if(($product_in_registry == false)){.

       $products_not_in_registry[] = $order->products[$i]['id'];.

     }.

   } // end for.

/*.

Print('<br>out of range:<br>');.

Print_r($products_out_of_range);.

Print('<br>not in registry:<br>');.

Print_r($products_not_in_registry);.

Exit();.

*/.

   //check if there are any products out of range.

   if(is_array($products_out_of_range) || is_array($products_not_in_registry)){.

     //if yes, we need to get back to the shopping cart, notify the customer and have him change the cart stuff.

     if (tep_session_is_registered('shipping')) tep_session_unregister('shipping');.

     if (tep_session_is_registered('payment')) tep_session_unregister('payment');.

     tep_redirect(tep_href_link(FILENAME_DISPLAY_REGISTRY_PRODUCTS, 'registry_id='$cart->registry_id'&info_message='REGISTRY_PRODUCT_ERROR));.

   }else{.

     //if not, we need to update the purchased items in the registry and provide the information to insert into the order table.

     for($i = 0; $i < sizeof($order->products); $i++){.

       $update_registry_count_query_string = "UPDATE "TABLE_REGISTRY_PRODUCTS" SET registry_products_quantity_received = registry_products_quantity_received + '"$order->products[$i]['qty']"' WHERE products_id = '"$order->products[$i]['id']"' AND  registry_id = '"$cart->registry_id"'";.

       tep_db_query($update_registry_count_query_string);.

     }.

   }.

 }.

//comment gift registry.

//maybe attemp to lock the DB (e.g. insert a unique number and check later if still the same to avoid paralell updates..

//the redirect to the registry again isn't 100% perfect. Task for the future to make it better..

//end gift registry.

 $sql_data_array = array('customers_id' => $customer_id,.

                         'customers_name' => $order->customer['firstname']' '$order->customer['lastname'],.

                         'customers_company' => $order->customer['company'],.

                         'customers_street_address' => $order->customer['street_address'],.

                         'customers_suburb' => $order->customer['suburb'],.

                         'customers_city' => $order->customer['city'],.

                         'customers_postcode' => $order->customer['postcode'],.

                         'customers_state' => $order->customer['state'],.

                         'customers_country' => $order->customer['country']['title'],.

                         'customers_telephone' => $order->customer['telephone'],.

                         'customers_email_address' => $order->customer['email_address'],.

                         'customers_address_format_id' => $order->customer['format_id'],.

                         'delivery_name' => $order->delivery['firstname']' '$order->delivery['lastname'],.

                         'delivery_company' => $order->delivery['company'],.

                         'delivery_street_address' => $order->delivery['street_address'],.

                         'delivery_suburb' => $order->delivery['suburb'],.

                         'delivery_city' => $order->delivery['city'],.

                         'delivery_postcode' => $order->delivery['postcode'],.

                         'delivery_state' => $order->delivery['state'],.

                         'delivery_country' => $order->delivery['country']['title'],.

                         'delivery_address_format_id' => $order->delivery['format_id'],.

                         'billing_name' => $order->billing['firstname']' '$order->billing['lastname'],.

                         'billing_company' => $order->billing['company'],.

                         'billing_street_address' => $order->billing['street_address'],.

                         'billing_suburb' => $order->billing['suburb'],.

                         'billing_city' => $order->billing['city'],.

                         'billing_postcode' => $order->billing['postcode'],.

                         'billing_state' => $order->billing['state'],.

                         'billing_country' => $order->billing['country']['title'],.

                         'billing_address_format_id' => $order->billing['format_id'],.

                         'payment_method' => $order->info['payment_method'],.

                         'cc_type' => $order->info['cc_type'],.

                         'cc_owner' => $order->info['cc_owner'],.

                         'cc_number' => $order->info['cc_number'],.

                         'cc_expires' => $order->info['cc_expires'],.

                         'date_purchased' => 'now()',.

                         'orders_status' => $order->info['order_status'],.

                         'currency' => $order->info['currency'],.

                         'currency_value' => $order->info['currency_value'],.

                         'ip_address' => $ip);.

 if(USE_REFERRAL_SYSTEM == 'true' && $customer_referral_points_spending) {.

   tep_set_referral_points(($customer_referral_points - $customer_referral_points_spending), $customer_id);.

 }  .

 tep_db_perform(TABLE_ORDERS, $sql_data_array);.

 $insert_id = tep_db_insert_id();.

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {.

   $sql_data_array = array('orders_id' => $insert_id,.

                           'title' => $order_totals[$i]['title'],.

                           'text' => $order_totals[$i]['text'],.

                           'value' => $order_totals[$i]['value'],.

                           'class' => $order_totals[$i]['code'],.

                           'sort_order' => $order_totals[$i]['sort_order']);.

   tep_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);.

 }.

 $customer_notification = (SEND_EMAILS == 'true') ? '1' : '0';.

 $sql_data_array = array('orders_id' => $insert_id,.

                         'orders_status_id' => $order->info['order_status'],.

                         'date_added' => 'now()',.

                         'customer_notified' => $customer_notification,.

                         'comments' => $order->info['comments']);.

 tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);.

// initialized for the email confirmation.

 $products_ordered = '';.

 $subtotal = 0;.

 $total_tax = 0;.

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {.

// Stock Update - Joao Correia.

   if (STOCK_LIMITED == 'true') {.

     if (DOWNLOAD_ENABLED == 'true') {.

       $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename.

                           FROM "TABLE_PRODUCTS" p.

                           LEFT JOIN "TABLE_PRODUCTS_ATTRIBUTES" pa.

                            ON p.products_id=pa.products_id.

                           LEFT JOIN "TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD" pad.

                            ON pa.products_attributes_id=pad.products_attributes_id.

                           WHERE p.products_id = '"tep_get_prid($order->products[$i]['id'])"'";.

// Will work with only one option for downloadable products.

// otherwise, we have to build the query dynamically with a loop.

       $products_attributes = $order->products[$i]['attributes'];.

       if (is_array($products_attributes)) {.

         $stock_query_raw .= " AND pa.options_id = '"$products_attributes[0]['option_id']"' AND pa.options_values_id = '"$products_attributes[0]['value_id']"'";.

       }.

       $stock_query = tep_db_query($stock_query_raw);.

     } else {.

       $stock_query = tep_db_query("select products_quantity from "TABLE_PRODUCTS" where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

     }.

     if (tep_db_num_rows($stock_query) > 0) {.

       $stock_values = tep_db_fetch_array($stock_query);.

// do not decrement quantities if products_attributes_filename exists.

       if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {.

         $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];.

       } else {.

         $stock_left = $stock_values['products_quantity'];.

       }.

       tep_db_query("update "TABLE_PRODUCTS" set products_quantity = '"$stock_left"' where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

       if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {.

         tep_db_query("update "TABLE_PRODUCTS" set products_status = '0' where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

       }.

     }.

   }.

// Update products_ordered (for bestsellers list).

   tep_db_query("update "TABLE_PRODUCTS" set products_ordered = products_ordered + "sprintf('%d', $order->products[$i]['qty'])" where products_id = '"tep_get_prid($order->products[$i]['id'])"'");.

//start gift registry.

   $sql_data_array = array('orders_id' => $insert_id,.

                           'products_id' => tep_get_prid($order->products[$i]['id']),.

                           'products_model' => $order->products[$i]['model'],.

                           'products_name' => $order->products[$i]['name'],.

                           'products_price' => $order->products[$i]['price'],.

                           'final_price' => $order->products[$i]['final_price'],.

                           'products_tax' => $order->products[$i]['tax'],.

                           'products_quantity' => $order->products[$i]['qty'],.

                           'registry_products_id' => $order->products[$i]['registry_products_id'],.

                           'registry_products_customers_id ' => $order->products[$i]['registry_products_customers_id']);.

//end gift registry.

   tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);.

   $order_products_id = tep_db_insert_id();.

   $order_total_modules->update_credit_account($i);//ICW ADDED FOR CREDIT CLASS SYSTEM.

//insert customer choosen option to order.

   $attributes_exist = '0';.

   $products_ordered_attributes = '';.

   if (isset($order->products[$i]['attributes'])) {.

     $attributes_exist = '1';.

     for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {.

       if (DOWNLOAD_ENABLED == 'true') {.

         $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename.

                              from "TABLE_PRODUCTS_OPTIONS" popt, "TABLE_PRODUCTS_OPTIONS_VALUES" poval, "TABLE_PRODUCTS_ATTRIBUTES" pa.

                              left join "TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD" pad.

                               on pa.products_attributes_id=pad.products_attributes_id.

                              where pa.products_id = '"$order->products[$i]['id']"'.

                               and pa.options_id = '"$order->products[$i]['attributes'][$j]['option_id']"'.

                               and pa.options_id = popt.products_options_id.

                               and pa.options_values_id = '"$order->products[$i]['attributes'][$j]['value_id']"'.

                               and pa.options_values_id = poval.products_options_values_id.

                               and popt.language_id = '"$languages_id"'.

                               and poval.language_id = '"$languages_id"'";.

         $attributes = tep_db_query($attributes_query);.

       } else {.

         $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from "TABLE_PRODUCTS_OPTIONS" popt, "TABLE_PRODUCTS_OPTIONS_VALUES" poval, "TABLE_PRODUCTS_ATTRIBUTES" pa where pa.products_id = '"$order->products[$i]['id']"' and pa.options_id = '"$order->products[$i]['attributes'][$j]['option_id']"' and pa.options_id = popt.products_options_id and pa.options_values_id = '"$order->products[$i]['attributes'][$j]['value_id']"' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '"$languages_id"' and poval.language_id = '"$languages_id"'");.

       }.

       $attributes_values = tep_db_fetch_array($attributes);.

       $sql_data_array = array('orders_id' => $insert_id,.

                               'orders_products_id' => $order_products_id,.

                               'products_options' => $attributes_values['products_options_name'],.

                               'products_options_values' => $attributes_values['products_options_values_name'],.

                               'options_values_price' => $attributes_values['options_values_price'],.

                               'price_prefix' => $attributes_values['price_prefix']);.

       tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);.

       if ((DOWNLOAD_ENABLED == 'true') && isset($attributes_values['products_attributes_filename']) && tep_not_null($attributes_values['products_attributes_filename'])) {.

         $sql_data_array = array('orders_id' => $insert_id,.

                                 'orders_products_id' => $order_products_id,.

                                 'orders_products_filename' => $attributes_values['products_attributes_filename'],.

                                 'download_maxdays' => $attributes_values['products_attributes_maxdays'],.

                                 'download_count' => $attributes_values['products_attributes_maxcount']);.

         tep_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);.

       }.

       $products_ordered_attributes .= "\n\t"$attributes_values['products_options_name']' '$attributes_values['products_options_values_name'];.

     }.

   }.

//insert customer choosen option eof.

   $total_weight += ($order->products[$i]['qty'] * $order->products[$i]['weight']);.

   $total_tax += tep_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty'];.

   $total_cost += $total_products_price;.

   $products_ordered .= $order->products[$i]['qty']' x '$order->products[$i]['name']' ('$order->products[$i]['model']') = '$currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty'])$products_ordered_attributes"\n";.

 }.

$order_total_modules->apply_credit();//ICW ADDED FOR CREDIT CLASS SYSTEM.

// lets start with the email confirmation.

//start gift registry.

 $email_order = STORE_NAME"\n\n".

       STORE_INFO"\n" ..

                EMAIL_SEPARATOR"\n".

                EMAIL_TEXT_ORDER_NUMBER' '$insert_id"\n" ..

                EMAIL_TEXT_INVOICE_URL' 'tep_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id='$insert_id, 'SSL', false)"\n" ..

                EMAIL_TEXT_DATE_ORDERED' 'strftime(DATE_FORMAT_LONG)"\n\n";.

 $email_order_registry = STORE_NAME"\n".

                         EMAIL_SEPARATOR"\n".

                         EMAIL_TEXT_ORDER_NUMBER' '$insert_id"\n" ..

                         EMAIL_TEXT_DATE_ORDERED' 'strftime(DATE_FORMAT_LONG)"\n\n";.

 if ($order->info['comments']) {.

   $email_order .= tep_db_output($order->info['comments'])"\n\n";.

 }.

 $email_order .= EMAIL_TEXT_PRODUCTS"\n".

                 EMAIL_SEPARATOR"\n".

                 $products_ordered.

                 EMAIL_SEPARATOR"\n";.

 $email_order_registry .= EMAIL_TEXT_PRODUCTS"\n".

                          EMAIL_SEPARATOR"\n".

                          $products_ordered.

                          EMAIL_SEPARATOR"\n\n";.

 for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {.

   $email_order .= strip_tags($order_totals[$i]['title'])' 'strip_tags($order_totals[$i]['text'])"\n";.

 }.

 $delivery_label = '';.

 if($cart->registry_customers_id == '0'){.

   $delivery_label = tep_address_label($customer_id, $sendto, 0, '', "\n");.

 }else{.

   $delivery_label = tep_address_label($cart->registry_customers_id, tep_get_default_address($cart->registry_customers_id), 0, '', "\n");.

 }.

 if ($order->content_type != 'virtual') {.

   $email_order .= "\n"EMAIL_TEXT_DELIVERY_ADDRESS"\n".

                   EMAIL_SEPARATOR"\n" ..

                   $delivery_label"\n";.

   $email_order_registry .= "\n"EMAIL_TEXT_DELIVERY_ADDRESS"\n".

                                   EMAIL_SEPARATOR"\n" ..

                                   $delivery_label"\n";.

 }.

 $email_order .= "\n"EMAIL_TEXT_BILLING_ADDRESS"\n" ..

                 EMAIL_SEPARATOR"\n" ..

                 tep_address_label($customer_id, $billto, 0, '', "\n")"\n\n";.

 $email_order_registry .= "\n"EMAIL_TEXT_BILLING_ADDRESS"\n" ..

                          EMAIL_SEPARATOR"\n" ..

                          tep_address_label($customer_id, $billto, 0, '', "\n")"\n\n";.

 if (is_object($$payment)) {.

   $email_order .= EMAIL_TEXT_PAYMENT_METHOD"\n".

                   EMAIL_SEPARATOR"\n";.

   $payment_class = $$payment;.

   $email_order .= $payment_class->title"\n\n";.

   if ($payment_class->email_footer) {.

     $email_order .= $payment_class->email_footer"\n\n";.

   }.

 }.

 tep_mail($order->customer['firstname']' '$order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);.

 if($cart->registry_customers_id != '0'){.

   $mail_info = tep_get_registry_email_info($cart->registry_customers_id);.

   tep_mail($mail_info['customers_firstname']' '$mail_info['customers_lastname'], $mail_info['customers_email_address'], EMAIL_TEXT_SUBJECT_REGISTRY, nl2br($email_order_registry), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');.

 }.

//end gift registry.

// send emails to other people.

 if (SEND_EXTRA_ORDER_EMAILS_TO != '') {.

   tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);.

 }.

// load the after_process function from the payment modules.

 $payment_modules->after_process();.

 $cart->reset(true);.

// unregister session variables used during checkout.

 tep_session_unregister('sendto');.

 tep_session_unregister('billto');.

 tep_session_unregister('shipping');.

 tep_session_unregister('payment');.

 tep_session_unregister('comments');.

If(tep_session_is_registered('credit_covers')) tep_session_unregister('credit_covers');.

 $order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM.

 tep_redirect(tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));.

 require(DIR_WS_INCLUDES'application_bottom.php');.

?>..

Comment #12

Hmm... I seem to have fixed it by closing off the two brackets in lines 69 and 70:.

If(USE_REFERRAL_SYSTEM == 'true') {.

   if(tep_session_is_registered('customer_referral_referred') && REFERRAL_ACCEPT_METHOD == 'checkout') {.

         tep_add_referral_point($customer_referral_referred);.

The only strange thing is... this code isn't related to my recent installation. It was working fine after I installed the referral system...

Comment #13


This question was taken from a support group/message board and re-posted here so others can learn from it.