OK, here are the changes I made. I recommend testing them on a test site since I was using the earlier version of auto facebook (version 2.0) and there might be some compatibility issues with a newer version of the module. You will need to add an extra field to the db products table so you should back up your db before doing this. Also, this is on 1.3.9h so there may or may not be differences in where to place the new code in 1.5.x but it should still work.
Insert this using phpmyadmin or in the sql patch in the admin. The db field, you might need to change the table name if you add prefixes so table products might become table zen_products or whatever:
Code:
ALTER TABLE `products` ADD `facebook_add` tinyint(1) NOT NULL DEFAULT '0';
In admin/includes/modules/product/collect_info.php around line 41 look for this line
PHP Code:
'master_categories_id' => ''
and change it to
PHP Code:
'master_categories_id' => '',
'facebook_add' => ''
around line 59 look for
PHP Code:
p.master_categories_id
and change to
PHP Code:
p.master_categories_id, p.facebook_add
around line 150 look for this
PHP Code:
// Products can be purchased with mixed attributes retail
if (!isset($pInfo->products_quantity_mixed)) $pInfo->products_quantity_mixed = '0';
switch ($pInfo->products_quantity_mixed) {
case '0': $in_products_quantity_mixed = false; $out_products_quantity_mixed = true; break;
case '1': $in_products_quantity_mixed = true; $out_products_quantity_mixed = false; break;
default: $in_products_quantity_mixed = true; $out_products_quantity_mixed = false;
}
and after it add this
PHP Code:
if (!isset($pInfo->facebook_add)) $pInfo->facebook_add = '0';
switch ($pInfo->facebook_add) {
case '0': $is_facebook_add_enabled = false; $not_facebook_add_enabled = true; break;
case '1': $is_facebook_add_enabled = true; $not_facebook_add_enabled = false; break;
default: $is_facebook_add_enabled = false; $not_facebook_add_enabled = true;
}
around line 412 look for this
PHP Code:
<tr>
<td class="main"><?php echo TEXT_PRODUCT_IS_FREE; ?></td>
and right above it add this
PHP Code:
<tr>
<td class="main">Add/update Facebook?</td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('facebook_add', '1', $is_facebook_add_enabled) . ' Yes ' . zen_draw_radio_field('facebook_add', '0', $not_facebook_add_enabled) . ' No ' . ($pInfo->facebook_add == 1 ? 'Add to facebook?' : ''); ?></td>
</tr>
You can add the above line of code anywhere in that table that suits your preference, I just found it convenient to add it there.
In admin/includes/modules/product/preview_info.php look around line 26 for
PHP Code:
p.products_sort_order
and change to
PHP Code:
p.products_sort_order, p.facebook_add
around line 74 look for
PHP Code:
echo zen_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description;
}
?>
</td>
</tr>
and change it to
PHP Code:
echo zen_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description;
}
?>
<!--BO FACEBOOK-->
</tr><tr>
<td><hr></td>
</tr><tr>
<td class="smallText">
<?php
$facebook_add = $_POST['facebook_add'];
if ($facebook_add == 1) {
echo "Facebook Will be Updated.";
} else {
echo "Facebook Will NOT be Updated.";
}
?>
</td> </tr>
<tr>
<!--EO FACEBOOK-->
</td>
</tr>
This gives you a message on the preview page of whether or not facebook will be updated.
In admin/includes/modules/update_product.php around line 9 look for
PHP Code:
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
and after add this
PHP Code:
$facebook_add = $_POST['facebook_add'];
around line 52 look for
PHP Code:
'products_price_sorter' => zen_db_prepare_input($_POST['products_price_sorter'])
and change it to
PHP Code:
'products_price_sorter' => zen_db_prepare_input($_POST['products_price_sorter']),
'facebook_add' => zen_db_prepare_input($_POST['facebook_add'])
around line 87 look for
PHP Code:
//// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
and below it add
PHP Code:
if ($facebook_add == 1) {
Now, this is where one of the main auto facebook code is in my site, I do not know if this is still the case with other/newer versions of this module. If the auto facebook code block is still there then at the end of it you will need to add
around line 104 look for
PHP Code:
//// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////
and insert below
PHP Code:
if ($facebook_add == 1) {
And again there is the second block of facebook code to which you will need to add this to the end of the facebook code block
I just tested this and it is still adding a product to fb when I choose the option to add it. BUT, and this may have been sorted or not with other versions, the html in the description like <p> is included in the fb listing and is not stripped/converted by fb like it used to be. I looked into it and it's an easy fix. In update_products if there is this line (it's there twice in mine)
PHP Code:
$prod_description = $_POST['products_description'][$_SESSION['languages_id']];
change to
PHP Code:
$prod_description = strip_tags($_POST['products_description'][$_SESSION['languages_id']]);
and now all html tags are stripped from the product description.
Also, my changes in update_product should be able to be applied to newer/different versions of the module as long as the last 2 edits ( adding if ($facebook_add == 1) { and then the closing } at the end of the block) are added wherever the new fb code blocks are. I say should, because I can't say for sure if it will work since I haven't tried it.
I am using the version 2.0 and it's working perfectly especially now I got the html tags stripped from the product descriptions, so I have never bothered to change what ain't broke. Like I said, this may or may not work with newer versions. I can try to help if there are major changes in the code in the new version.
Bookmarks