Tag Archives: cre loaded

Warning: no file uploaded – how to fix this error

Although this fix is for out-of-date oscommerce 2.2 and 4 years overdue, it may be of use for those yet to upgrade.

By default a warning will be shown at the top of the admin when a preview of a product is shown, when the product has not had an image attached or reedited.

The reason for this is the code doesn’t allow for a product not to have an image added at time of editing – ie, if it already has the correct image added to it, no other image would be attached to it, right?

The file to edit is /admin/includes/classes/upload.php


 } else {
        if ($this->message_location == 'direct') {
          $messageStack->add(WARNING_NO_FILE_UPLOADED, 'warning');
        } else {
          $messageStack->add_session(WARNING_NO_FILE_UPLOADED, 'warning');

Change to:

 } else {
      if (!empty($file['tmp_name'])){
        if ($this->message_location == 'direct') {
          $messageStack->add('search', WARNING_NO_FILE_UPLOADED, 'warning');
        } else {
          $messageStack->add_session('search', WARNING_NO_FILE_UPLOADED, 'warning');

There are several solutions given to this problem – here’s one that is just plain wrong:

products attributes not showing on confirmation email

This bug which causes the product attribute information not to appear on order confirmation emails sent by the Cre Loaded or Loaded Commerce admin has been around forever on Cre Loaded (and now Loaded Commerce 6.5.x) carts.

Replicate as follows:
1. Admin >> Configuration >> Download … set ‘Enable Download’ to false

2. Place order for product with attributes
3. Receive email without mention of product attributes

The fix:
Find the file /checkout_process.php, backup first, then anywhere from line 450 through to 510 (depends on your version) replace with the block as shown

$products_ordered_attributes = '';
  if (isset($order->products[$i]['attributes'])) {
    for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
      $sql_data_array = array('orders_id' => $insert_id,
                              'orders_products_id' => $order_products_id,
                              'products_options' => $order->products[$i]['attributes'][$j]['option'],
                              'products_options_values' => $order->products[$i]['attributes'][$j]['value'],
                              'options_values_price' => $order->products[$i]['attributes'][$j]['price'],
                              'price_prefix' => $order->products[$i]['attributes'][$j]['prefix'],
                              'products_options_id' => $order->products[$i]['attributes'][$j]['option_id'],
                              'products_options_values_id' => $order->products[$i]['attributes'][$j]['value_id']);
      tep_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
      if (DOWNLOAD_ENABLED == 'true') {
        $attributes_query = "select pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename
                               from " . TABLE_PRODUCTS_ATTRIBUTES . " pa,
                                    " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
                             where pa.products_id = '" . $order->products[$i]['id'] . "'
                               and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'
                               and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'
                               and pa.products_attributes_id = pad.products_attributes_id";
        $attributes = tep_db_query($attributes_query);
        $attributes_values = tep_db_fetch_array($attributes);
        if ( 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);
        } // download filename loop ends
      }  // download attributes loop ends

        if( (!empty($order->products[$i]['attributes'])) ){
          $products_ordered_attributes .= "\n\t" . (isset($order->products[$i]['attributes'][$j]['option']) ? $order->products[$i]['attributes'][$j]['option'] : '') . ' ' . (isset($order->products[$i]['attributes'][$j]['value']) ? $order->products[$i]['attributes'][$j]['value'] : '') . ' ' .
          ( (isset($order->products[$i]['attributes'][$j]['price']) && ($order->products[$i]['attributes'][$j]['price'] > 0) ?
           $order->products[$i]['attributes'][$j]['prefix'] . ' ' . $currencies->display_price($order->products[$i]['attributes'][$j]['price'], tep_get_tax_rate($products[$i]['tax_class_id']), 1): ''));

      } // attributes not empty loop
    } // loop through the attributes
  }  // attributes set?

tinymce editor box outlines visible when editing product

If you’re seeing outline boxes appearing in product edit pages of your 6.4.x or earlier cart caused by the tinymce editor, like this:

here’s the fix:

file: admin/editors/tiny_mce.php, around line 57


    echo "n";




if(substr($textarea, -1, 1) == ','){
     $textarea = substr($textarea,0,-1);
    echo "n";


how to upgrade oscommerce-based scripts from php 5.2.x to php 5.3.x

More and more hosting companies are upgrading their servers to run php 5.3. For most carts, this will mean an error log file full of deprecated error messages – warnings that one day, the functions being used will be removed entirely and the script will break.

If you’re running an older version of your oscommerce-based cart software (eg Cre Loaded 6.4.1, Oscommerce 2.2 etc) you will find that your error log file will fill up with deprecated messages from a number of files still using old calls like ‘ereg’ and ‘ereg_replace.’

You could switch these error messages off if you can control the error_reporting configuration on the server you’re on, but there’s a chance that when php 5.4 is adopted by hosting companies (RC6 of this was released January 2012) many of these deprecated messages now will become broken scripts then.

Updating most of these old calls can be fairly easy – here is a reference table that will help:

ereg() = preg_match()
ereg_replace() = preg_replace()
eregi() = preg_match() with the 'i' modifier
eregi_replace() = preg_replace() with the 'i' modifier
split() = preg_split()
spliti() = preg_split() with the 'i' modifier

As an example – cre loaded 6.4.1a B2B file /includes/functions/general.php :

if (ereg('^[0-9]+$', $value)) {

would become

if (preg_match('/^[0-9]+$/', $value)) {

(note ereg becomes preg_match and the forward slashes (delimiters) are added in)

Other deprecated functions and directives are more involved and may in fact only be configurable by the hosting company if they don’t allow custom php.ini files. There are other examples in the code that can simply be removed to upgrade to php 5.3.x and will stop the deprecated message.

A popular old check in Cre Loaded is a 6.2 version check – this from /admin/includes/runtime/orders/RC_orders_boxesbottom.php:

  if (defined('PROJECT_VERSION') && ereg('6.2', PROJECT_VERSION)) {
    $rci = tep_admin_files_boxes(FILENAME_RECOVER_ABANDONED_CARTS, BOX_RECOVER_ABANDONED_CARTS, 'SSL','tdate=' . $tdate, '0');
  } else {
    $rci = tep_admin_files_boxes(FILENAME_RECOVER_ABANDONED_CARTS, BOX_RECOVER_ABANDONED_CARTS, 'SSL','tdate=' . $tdate, '2');

In this case the ‘upgrade’ would be to remove the old version check (bypassing the need for the deprecated ereg check.)

Third-party modules may cause grief when your hosting company upgrades to php 5.3.
At the time of writing this, Magneticone’s modules that use Zend Optimizer for decoding will break as Zend hasn’t provided a backward compatible version of the ZO for scripts using php 5.2.x. Magneticone’s advice in this situation is to use the ioncube versions of the scripts only (as they haven’t upgraded their modules to use the standalone ZO php 5.3 version either.) Nuisance.

If you’re unsure about these changes, contact me for a quote to help you upgrade from php 5.2 to php 5.3

set default payment method in checkout

Sometimes its helpful to have a payment method ‘preselected’ for customers in the checkout area, so they avoid getting an error message if they miss that option. Or maybe you want to select a method for them as an example of what it looks like … plenty of reasons. This short article explains how to set a default payment method in oscommerce 2.2 and cre loaded 6.4.1a carts (which is slightly harder as cre is using runoverride files now to ‘steer things in a paypal direction.’)

Oscommerce 2.2 version
Backup the file: /catalog/checkout_payment.php and edit as follows:

        if (sizeof($selection) > 1) {
          echo tep_draw_radio_field('payment', $selection[$i]['id']);
        } else {
          echo tep_draw_hidden_field('payment', $selection[$i]['id']);

Replace with:

          if (sizeof($selection) > 1) {
          if ($i == 0) { 
                $checked = true;          
                } else {  
           $checked = false;      
                echo tep_draw_radio_field('payment', $selection[$i]['id'], $checked);
           } else { 
                echo tep_draw_hidden_field('payment', $selection[$i]['id']);

Cre Loaded 6.4.1a
Backup the file: /catalog/includes/runoverride/ordercheckout/paypalxc_ordercheckout_paymentmodule.php

To get the selector bar highlighting the payment method row, modify as follows, replacing the payment method name in the ‘name of payment method’ bit:

 $radio_buttons = 0;
        $payment = (!$payment) ? 'name of the payment method' : $payment;
 for ($i=0, $n=sizeof($selection); $i<$n; $i++) {

If you’re not sure of the payment module names, go to Admin >> Modules >> Payment area, click on a module and read it’s name from the url in the address bar. Or just check in the /includes/modules/payment folder and drop the .php extension.

To get the radio button to default to the selected payment module, modify the following:

  if (sizeof($selection) > 1 || $ec_enabled ) {
   if ($i == 0) {  // defaults to payment method with id=0 NOT related to sort order in admin
      $checked = true;
   } else {
      $checked = false;
  echo tep_draw_radio_field('payment', $selection[$i]['id'], $checked);
  } else {  ...

The key part in the code is the $i==0 which refers to the payment method id. This ISN’T related to the sort order of the payment modules in the Admin >> Modules >> Payment area, or some ‘name sort’ principle. Instead it just reflects the order of the modules in the database constant MODULE_PAYMENT_INSTALLED.

So if you take a look at the configuration table in your database and search for MODULE_PAYMENT_INSTALLED, your payment modules will be in a row there –
eg moneyorder.php,transfer.php,paypal.php
Here, moneyorder will have the id = 0 (so $i == 0 to be selected by default), transfer’s id = 1, paypal’s id = 2 … etc.

So by changing the $i == 0 in the code examples above to match your payment method id, you can easily set the default payment method at checkout.