I updated to this
Code:
<script type="text/javascript">
document.forms['<?php echo $form_action;?>'].submit();auto submit form
document.title = "Preview:" + document.title;//prefix title so it shows up in browser Back button/history as distinct to product data entry page
</script>
and for belt and braces,
in ADMIN/product.php
case 'new_product_preview':
if (isset($_POST) && $_POST['master_categories_id'] !='' ) {//steve added next line and clause to prevent empty POST overwriting product info
if (
file_exists(
DIR_WS_MODULES .
$zc_products->get_handler(
$product_type) .
'/new_product_preview.php')) {
require(
DIR_WS_MODULES .
$zc_products->get_handler(
$product_type) .
'/new_product_preview.php');
}
else {
require(
DIR_WS_MODULES .
'new_product_preview.php');
}
} else {//steve bof, bail out to categories root
zen_redirect(zen_href_link(FILENAME_CATEGORIES));
}//eofbreak;
Why?
Now and again I would find a product with an empty master_categories id.
https://www.zen-cart.com/showthread...._category_id-0
If after editing and saving a product, I did some other admin stuff then used the navigator Back/history button to go back to Edit Product BUT instead went back to the Preview page by mistake, there was no POST info set.
This variable contains all the product info (including its master category) but now it is empty. The page then autosubmits/saves the product with all its fields empty effectively wiping out the product.
Bookmarks