PDA

View Full Version : How to Set Default Text in Product Info Tabs



Glen Piggott
06-11-2014, 07:28 AM
Hi Everyone

I'm trying to set some default text for the product info tabs so that every time our client adds a new product they don't have to add the same text into the tabs over and over again. For example delivery info which is the same for every product.

In the file catalog > admin > categories.php from line 1139 there seems to be where you can add default values to the product fields. On line 1165 I've got
'products_weight' => '1.000', which does add 1.000 into the product weight box every time you go to add a new product, which is perfect!

I've tried to do the same on line 1146 for
'tab1' => '', but whatever I add into this doesn't come up in the product info tab 1 when inserting a new product. As the tabs are WYSIWYG editors I'm trying to add HTML as the default so I don't know if this is the problem?

Any help would be gratefully received.

pgmarshall
06-12-2014, 12:53 AM
By far and away the easiest way to do this (assuming you only have a single language) is to hard code it into the product_tabs.php file in catalog/includes/modules/

Simply add an additional tab group.



<div class="panel" id="tab7">
<h4>Delivery Information</h4>
Put your standard delivery text and HTML here ...
</div>


If you still want to use categories.php then you should be editing around line 623 when the database save is made.


'tab6' => tep_db_prepare_input($_POST['tab6'][$language_id]),

Should be (untested so make sure you have a backup)


'tab6' => tep_db_prepare_input("<div><h4>Delivery Information</h4><p>This is where your standard text goes.</p></div>"),

Hope this helps.

Regards.

Glen Piggott
06-14-2014, 05:14 AM
Hi pgmarshall

Many thanks for your replay and help.

Originally I did include the default text in catalog/includes/modules/product_tabs.php file as you first suggest but the problem with this is that it's not editable via the admin, which it needs to be as a small number of products have a different returns policy.

My aim was to include the default tab HTML so that when the client adds a new product, the HTML in the tabs was automatically populated with the default HTML but then could be edited if required.

Your suggestion for catalog/admin/categories.php works but unfortunately every time you save the product information it overwrites any changes made in the tabs. I was hoping inserting it around line 1146 would be the answer!

Thank you.

ridexbuilder
06-14-2014, 10:02 AM
Could you not use Extra Product Fields and display the values in the appropriate Tab?
This way it will be editable in Admin. and can be assigned on a per product basis.

pgmarshall
06-16-2014, 01:58 PM
Your suggestion for catalog/admin/categories.php works but unfortunately every time you save the product information it overwrites any changes made in the tabs.

Yes - well this is what you asked for! If you had asked for some default text that you could then edit I would have told you do the following - lesson: ensure you ask the right question!

Anyway ... open admin/includes/functions/general.php and find:



function tep_get_tab6($product_id, $language_id) { $product_query = tep_db_query("select tab6 from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

return $product['tab6']; }

and change it to:



function tep_get_tab6($product_id, $language_id) { $product_query = tep_db_query("select tab6 from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

if ($product['tab6'] == '') {
$product['tab6'] = 'This is an example of some stuff to add.';
}

return $product['tab6']; }

This way if the field is blank then it will add the default text ... downside is that this MUST be filled ... because if it isn't then it will add the default. You could put some spaces in but then the tab will show!

Anyway, you should have enough here to hack something together for your client.

Regards.

Glen Piggott
06-17-2014, 12:57 AM
Yes - well this is what you asked for! If you had asked for some default text that you could then edit I would have told you do the following - lesson: ensure you ask the right question!.

Opps sorry, consider my wrists slapped and lesson learnt!

That seems to work a treat - thank you sooooo much!