Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Skip Preview on Product Insert or Update


Guest

Recommended Posts

Posted

In admin/categories.php find this code:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

...and change it to this:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?
switch($_GET['action']){
case 'new_product_preview':
 $onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
 break;
default:
 $onload = 'SetFocus();';
 break;
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">

...all done.

 

Now on new product insert or existing product update it will skip the preview page completely (actually, auto submit instantly on page load).

 

Enjoy!

 

Bobby

Posted

chemo....thaaaaaank you. ive been trying to do this but with my limited php knowledge the only results ive been getting are error messages. im sure this will help many others !

  • 1 month later...
Posted
In admin/categories.php find this code:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

...and change it to this:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?
switch($_GET['action']){
case 'new_product_preview':
 $onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
 break;
default:
 $onload = 'SetFocus();';
 break;
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">

...all done.

 

Now on new product insert or existing product update it will skip the preview page completely (actually, auto submit instantly on page load).

 

Enjoy!

 

Bobby

 

Hi Bobby,

 

GREAT hack BUT.....

 

It all worked great but when you double click on a product in the products list under it's catagory then the product gets deleted!

 

Did anyone else experience this?

I'm having a great Day - hope you are too!

 

Leon

Posted
Hi Bobby,

 

GREAT hack BUT.....

 

It all worked great but when you double click on a product in the products list under it's catagory then the product gets deleted!

 

Did anyone else experience this?

 

Yep. I have the same problem

Posted

Hmmm this was exactly what i was searching for, but the last 2 posts are a bit worrysome, which make me a bit unsure if it is wise to implement this great modification since it is a bit scary that you can actually delete products so easy (which sooner or later is bound to happen!)

 

 

 

Anybody figured it out yet?

Posted
Hmmm this was exactly what i was searching for, but the last 2 posts are a bit worrysome, which make me a bit unsure if it is wise to implement this great modification since it is a bit scary that you can actually delete products so easy (which sooner or later is bound to happen!)

Anybody figured it out yet?

 

 

Anyone Fixed this yet???

  • 4 weeks later...
Posted

Here is the fix for the problem where the product is "deleted" (actually emptied of data...) when you click the product line to preview it:

 

Between the </head> and <body....... lines make it like this:

 

</head>

<?

if ($_GET['read'] != "only") {

switch($_GET['action']){

case 'new_product_preview':

$onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';

break;

case 'new_master_preview':

$onload = isset($_GET['pID']) ? 'document.update_master.submit();' : 'document.insert_master.submit();';

break;

default:

$onload = 'SetFocus();';

break;

}

} else {

$onload = 'SetFocus();';

}

?>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">

 

There! You might want to change the Preview Button to Save....

 

SORRY about the tabbing and spacing, for some reason I cannot get the input to do it.... I edited it three times trying, I am done. duhhhhh

  • 2 years later...
  • 3 months later...
Posted

Hi

I really want this, but I already have an onload in my body from ajax attribute manager.

Any idea how to get this anyway?

  • 3 months later...
Posted
Hi

I really want this, but I already have an onload in my body from ajax attribute manager.

Any idea how to get this anyway?

 

You can use this (if you're using rbartz fix):

 

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="goOnLoad();<? echo $onload; ?>">

  • 2 weeks later...
Posted

I added this code to my file but I still have to preview the items then update.

Here is what my code looks like now. Do you see anything missing?

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<?

if ($_GET['read'] != "only") {switch($_GET['action']){case 'new_product_preview':$onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';break;case 'new_master_preview':$onload = isset($_GET['pID']) ? 'document.update_master.submit();' : 'document.insert_master.submit();';break;default:$onload = 'SetFocus();';break;}} else {$onload = 'SetFocus();';}?>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

  • 4 months later...
Posted
Hi

I really want this, but I already have an onload in my body from ajax attribute manager.

Any idea how to get this anyway?

You can have more than one statement in an onLoad statement- Just separate them with a semicolon...HTH

Posted

A different method I use that gives the option of instant update instead (adds a tick box)

 

after (18)

 

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

add:

 

 

 if ($_POST['instant_update'] == 'on') { 
  $products_image = new upload('products_image');
 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $_POST['products_image'] = $products_image->filename;
	} else {
	  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
	}

 $action = 'update_product';
}

 

after (596)

 

<tr>
		<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

 

add:

 

<tr>
	<td class="main" align="right">Update without preview <?php echo tep_draw_checkbox_field('instant_update', '', false); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

 

simple as that!! B)

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted

Minor Addendum:

 

I missed something:

 

 if ($_POST['instant_update'] == 'on') { 
  $products_image = new upload('products_image');
 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $_POST['products_image'] = $products_image->filename;
	} else {
	  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
	}

 $action = 'update_product';
}

 

Should be:

 

 if ($_POST['instant_update'] == 'on') { 
  $products_image = new upload('products_image');
 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $_POST['products_image'] = $products_image->filename;
	} else {
	  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
	}

$action =  (isset($_GET['pID'])) ? 'update_product' : 'insert_product';
}

 

Oops. :blush:

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

  • 3 weeks later...
Posted

@ spooks

 

Great code, better than the previous solution. But now the product_image doesnt get updated. Did anyone else get this error too?

 

Thanks and regards!

  • 3 months later...
Posted

Sam, I like your solution, but can you please add "before/after" instructions on where to modify ? - my line numbers are not the same as yours.

also, what's with the picture -updating ?

  • 5 months later...
Posted
Hi

I really want this, but I already have an onload in my body from ajax attribute manager.

Any idea how to get this anyway?

 

You can make this work with your AJAX Attribute module by changing rbarts code as follows:

 

FIND THIS:

 

$onload = 'SetFocus();';

break;

}

} else {

$onload = 'SetFocus();';

}

 

 

CHANGE TO THIS:

$onload = 'goOnLoad();';

break;

}

} else {

$onload = 'goOnLoad();';

}

 

That way when your not submitting an update or insert, the onLoad is set to what you need for AJAX.

:o)

David McGuffin - Website Developer

New Look Web Design

www.newlookwebdesign.com

---------------------------------------------------------------------

"I never memorize anything I can simply look up. . ." ~Albert Einstien

Posted

I forgot this, this is my latest code:

 

Open Admin/categories.php

find (18)

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

Add After:

 // instant update 
  if ($action == 'new_product_preview') {
// copy image only if modified
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}

if ($_POST['instant_update'] == 'on') { 
  $_POST['products_image'] = stripslashes($products_image_name);

$action =  (isset($_GET['pID']) ? 'update_product' : 'insert_product');  
		 }
				 }
// EOF instant update

 

Find(366)

 
case 'new_product_preview':
// copy image only if modified
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}
	break;

Replace with:

// section moved, instant update

 

Find (596)

 

<tr>
		<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

add after:

<tr>
	<td class="main" align="right">Update without preview <?php echo tep_draw_checkbox_field('instant_update', '', false); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Posted
I forgot this, this is my latest code:

 

Same thing, if you select a new picture, with the skip preview it doesnt get updated.

 

The rest works fine...

Posted

Find(366)

 
case 'new_product_preview':
// copy image only if modified
	$products_image = new upload('products_image');
	$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
	if ($products_image->parse() && $products_image->save()) {
	  $products_image_name = $products_image->filename;
	} else {
	  $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
	}
	break;

Replace with:

// section moved, instant update

[/font]

 

Sam, your tip sure is a step savings. I have mod - // BOF: [TiM's osC Solutions] - Better image upload features and the code you are referring to for line 366 is commented out. so is there a way I can incorapte your code into this or do i need to go Tims osc solutions for an answere?

 

this is Tims code:

	   case 'new_product_preview':
// copy image only if modified

	// BOF: [TiM's osC Solutions] - Better image upload features

	/*
	 * osCommerce is lacking a way to resample and reduce large uploaded photos.
	 * Additionally it's lacking a way to mark the uploaded files as temporary
	 * until admin presses the confirm button. This fixes that.
	 */

	  // check if uploaded file
	  if (is_uploaded_file($HTTP_POST_FILES['products_image']['tmp_name'])) {

	  // check if image directory exists and is writeable
	  if (!is_dir(DIR_FS_CATALOG_IMAGES)) mkdir(DIR_FS_CATALOG_IMAGES, 0777);
	  if (is_dir(DIR_FS_CATALOG_IMAGES)) {
		if (!is_writeable(DIR_FS_CATALOG_IMAGES)) {
		  $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
		  break;
		}
	  } else {
		$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
		break;
	  }

	  // check if products subdirectory exists and is writeable
	  if (!is_dir(DIR_FS_CATALOG_IMAGES . 'products/')) mkdir(DIR_FS_CATALOG_IMAGES . 'products/', 0777);
	  if (is_dir(DIR_FS_CATALOG_IMAGES . 'products/')) {
		if (!is_writeable(DIR_FS_CATALOG_IMAGES . 'products/')) {
		  $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
		  break;
		}
	  } else {
		$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
		break;
	  }

	  // require necessary files
	  require_once(DIR_FS_ADMIN . DIR_WS_CLASSES . 'images.php');

	  // create image object
	  $oImage = new TiM_image($HTTP_POST_FILES['products_image']['tmp_name']);

	  // resample image
	  $oImage->resample(400, 400, 'FIT_ONLY_BIGGER');

	  // watermark image
	  // uncomment the line below and enter a valid path to an alpha transparent png file
	  //$oImage->watermark('images/watermark.png', 'BOTTOM', 'RIGHT');

	  // set basename
	  $products_image_name = 'products/_tmp' . mktime() . '.jpg'; // temporary name for automatic renaming
	  //$products_image_name = 'products/' . $HTTP_POST_FILES['products_image']['name']; // keep original name

	  // save image
	  $oImage->write(DIR_FS_CATALOG_IMAGES . $products_image_name);

	// EOF: [TiM's osC Solutions] - Better image upload features

 

 

Thanks.

 

Bennett

Archived

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

×
×
  • Create New...