Re: AutoFacebook [Support]
Quote:
Originally Posted by
halogen.paul
Hi,
I will apologise first cause i am super new to all of this... i have been doing an install of zen cart for our shop and am slowly plodding through. I have got the shop working and mostly loaded now. I have a facebook page for the business and have installed autoFacebook to send updates to facebook... sadly nothing seems to be working for me. I have installed and uninstalled 3 times now in case i stuffed up somewhere and no joy... help please.
Zen cart is version 1.5.1
autofacebook 2.3
I have followed the video to the letter, even down to the update products as well as new products. When I add a new product or change a product my admin is not saying there has been an update to facebook. The facebook app is created and talking to me, as i have set the permissions, but i am now at a loss for what to do.
There is one nagging thought at the back of my head... i have installed a template for zen cart (picadilly posh) and maybe i should be installing to a different directory???
Thanx for any help in advance :-)
Any thoughts or ideas on this little dilemma of mine yet?
Re: AutoFacebook [Support]
Jamie, is there a way to change when the fb page gets updated with the new product. When I insert a new product into my store, I have it set to out of stock until I'm totally finished linking and updating metatags etc. The mod posts it before I have set it to in stock. Not sure what code would work. Can you help?
Joanne
Re: AutoFacebook [Support]
Anyone? Jamie? I'd really like to have an answer to this question.
Joanne
Re: AutoFacebook [Support]
I looked at this but for a short time. The video instructions online are difficult to follow and even tougher for those of us with hearing issues. It would be nice if instructions were in writing.
Re: AutoFacebook [Support]
Hey Doug, there is an html file in the download that has the instructions printed in it - just double click on the html file and it should open in your browser :)
Re: AutoFacebook [Support]
Quote:
Originally Posted by
joannem
Jamie, is there a way to change when the fb page gets updated with the new product. When I insert a new product into my store, I have it set to out of stock until I'm totally finished linking and updating metatags etc. The mod posts it before I have set it to in stock. Not sure what code would work. Can you help?
Joanne
It would be cool to have the option on the admin product update page to turn autofacebook on or off for that update.
Re: AutoFacebook [Support]
I would really like to display the Nett Price in facebook. The price that is displayed comes from price_sorter in the database, but the nett price is not stored in the database (or I can't find it).
Re: AutoFacebook [Support]
Hi, I got this module to work but the product description in Facebook shows html-tags and strange characters instead of swedish å.ä.ö? Anyone ran into this before?
Re: AutoFacebook [Support]
Quote:
Originally Posted by
coopco
I would really like to display the Nett Price in facebook. The price that is displayed comes from price_sorter in the database, but the nett price is not stored in the database (or I can't find it).
hi i got this to work with the zen_get_products_actual_price($products_id) i did have to use the substring to get rid of the zeros
not sure what way this would work with taxes etc but give it a try
PHP Code:
$price = substr(zen_get_products_actual_price($products_id),0,-2);
bn
1 Attachment(s)
Re: AutoFacebook [Support]
Quote:
Originally Posted by
joannem
Jamie, is there a way to change when the fb page gets updated with the new product. When I insert a new product into my store, I have it set to out of stock until I'm totally finished linking and updating metatags etc. The mod posts it before I have set it to in stock. Not sure what code would work. Can you help?
Joanne
i have added a switch on a per product basis, this switch works either creating a new product or editing an existing product, it defaults to no everytime you edit or create a product warning you that it has changed to no if it was previously set to yes
Attachment 12049
ok here is what i done, few weeks ago but think this is everything
any experienced zenners out there could look at the code in case there is something not done properly
1. Backup your database
2. Backup YOUR ADMIN/includes/modules/update_product.php
3. Backup YOUR ADMIN/includes/modules/product/collect_info.php
1. back up database then run the following sql from your zcadmin
PHP Code:
ALTER TABLE products ADD products_update_social_media tinyint(1) NOT NULL default '0';
2. edit YOUR ADMIN/includes/modules/update_product.php (sample from v1.51)
find the following code
PHP Code:
$sql_data_array = array('products_quantity' => $products_quantity,
'products_type' => zen_db_prepare_input($_GET['product_type']),
'products_model' => zen_db_prepare_input($_POST['products_model']),
'products_price' => $products_price,
'products_date_available' => $products_date_available,
'products_weight' => $products_weight,
'products_status' => zen_db_prepare_input((int)$_POST['products_status']),
'products_virtual' => zen_db_prepare_input((int)$_POST['products_virtual']),
'products_tax_class_id' => zen_db_prepare_input((int)$_POST['products_tax_class_id']),
'manufacturers_id' => $manufacturers_id,
'products_quantity_order_min' => zen_db_prepare_input($_POST['products_quantity_order_min']),
'products_quantity_order_units' => zen_db_prepare_input($_POST['products_quantity_order_units']),
'products_priced_by_attribute' => zen_db_prepare_input($_POST['products_priced_by_attribute']),
'product_is_free' => zen_db_prepare_input((int)$_POST['product_is_free']),
'product_is_call' => zen_db_prepare_input((int)$_POST['product_is_call']),
'products_quantity_mixed' => zen_db_prepare_input($_POST['products_quantity_mixed']),
'product_is_always_free_shipping' => zen_db_prepare_input((int)$_POST['product_is_always_free_shipping']),
'products_qty_box_status' => zen_db_prepare_input($_POST['products_qty_box_status']),
'products_quantity_order_max' => zen_db_prepare_input($_POST['products_quantity_order_max']),
'products_sort_order' => (int)zen_db_prepare_input($_POST['products_sort_order']),
'products_discount_type' => zen_db_prepare_input($_POST['products_discount_type']),
'products_discount_type_from' => zen_db_prepare_input($_POST['products_discount_type_from']),
'products_price_sorter' => zen_db_prepare_input($_POST['products_price_sorter'])
);
add the following code
PHP Code:
'products_update_social_media' => zen_db_prepare_input((int)$_POST['products_update_social_media']),
below
PHP Code:
'products_priced_by_attribute' => zen_db_prepare_input($_POST['products_priced_by_attribute']),
during your original install you added the following code to this file
PHP Code:
//AutoFacebook
$app_id = "Your App_ID Here"; //given when you created app
$app_secret = "Your App Secret Code Here"; //given when you created app
$page_id = "Page ID Here"; //obtained from running facebook_authorization.php from your browser
$page_token = "Page Token Here"; //long number obtained from facebook_authorization.php
$store_name = "Your Store"; // store name i.e. "Mary's Car Shop", or "MikesCupcakes.com."
$store_url = 'http://www.yourdomain.com'; //path to your store without the trailing "/"
$cur = '$'; //change to your currency symbol($, €, £, ¥, etc.). Assumes symbol comes in front of numbers
$new_message = "New Product Added"; // change to whatever or leave the same. i.e "New Cupcake!"
// No Need to edit below here.
$prod_image = $store_url . "/images/" . $_POST['products_image'];
$price = $products_price;
$prod_url = $store_url . '/index.php?main_page=product_info&cPath=' . $current_category_id . '&products_id=' . $products_id;
$prod_name = $_POST['products_name'][$_SESSION['languages_id']];
//webelity.com changed this line below to strip html tags from descriptions (Facebook does not support standard html input on descriptions via api calls)
$prod_description = $_POST['products_description'][$_SESSION['languages_id']];
//webelity.com changed this line below to strip html tags from descriptions (Facebook does not support standard html input on descriptions via api calls)
$info_strip = preg_replace('/(<\/[^>]+?>)(<[^>\/][^>]*?>)/', '$1 $2', $prod_description);
$description_stripped = strip_tags($info_strip);
//webelity.com 1-15-2012 added check to insure length does not reach the 10,000 character limit on descriptions in facebook.
$charset = 'UTF-8';
$no_description = 0;
$length = 9996;
if(mb_strlen($description_stripped, $charset) > $length) {
$facebook_description = mb_substr($description_stripped, 0, $length, $charset) . '...';
}
elseif(mb_strlen($description_stripped, $charset) == $no_description)
{
$facebook_description = "No description provided for this product.";
}
else
{
$facebook_description = $description_stripped;
}
include_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true, )
);
// webelity.com modfied currancy and price information and added facebook_description to lower array
$attachment = array(
'access_token' => $page_token,
'message' => $new_message . " - " . $prod_name,
'name' => $prod_name,
'link' => $prod_url,
'caption' => 'Price: ' . $cur . $price,
'description' => $facebook_description,
'picture' => $prod_image
);
try {
$status = $facebook->api($page_id.'/feed', 'post', $attachment);
$messageStack->add_session('Facebook was successfully updated!', 'success');
}
catch (FacebookApiException $fbe){
$fberror = $fbe->result['error']['message'];
$messageStack->add_session('Facebook Error: '.$fberror, 'error');
}
we need to add our code here for switch so it will now look like this
PHP Code:
//AutoFacebook
if ($_POST['products_update_social_media'] == '1') {
$app_id = "Your App_ID Here"; //given when you created app
$app_secret = "Your App Secret Code Here"; //given when you created app
$page_id = "Page ID Here"; //obtained from running facebook_authorization.php from your browser
$page_token = "Page Token Here"; //long number obtained from facebook_authorization.php
$store_name = "Your Store"; // store name i.e. "Mary's Car Shop", or "MikesCupcakes.com."
$store_url = 'http://www.yourdomain.com'; //path to your store without the trailing "/"
$cur = '$'; //change to your currency symbol($, €, £, ¥, etc.). Assumes symbol comes in front of numbers
$new_message = "New Product Added"; // change to whatever or leave the same. i.e "New Cupcake!"
// No Need to edit below here.
$prod_image = $store_url . "/images/" . $_POST['products_image'];
$price = $products_price;
$prod_url = $store_url . '/index.php?main_page=product_info&cPath=' . $current_category_id . '&products_id=' . $products_id;
$prod_name = $_POST['products_name'][$_SESSION['languages_id']];
//webelity.com changed this line below to strip html tags from descriptions (Facebook does not support standard html input on descriptions via api calls)
$prod_description = $_POST['products_description'][$_SESSION['languages_id']];
//webelity.com changed this line below to strip html tags from descriptions (Facebook does not support standard html input on descriptions via api calls)
$info_strip = preg_replace('/(<\/[^>]+?>)(<[^>\/][^>]*?>)/', '$1 $2', $prod_description);
$description_stripped = strip_tags($info_strip);
//webelity.com 1-15-2012 added check to insure length does not reach the 10,000 character limit on descriptions in facebook.
$charset = 'UTF-8';
$no_description = 0;
$length = 9996;
if(mb_strlen($description_stripped, $charset) > $length) {
$facebook_description = mb_substr($description_stripped, 0, $length, $charset) . '...';
}
elseif(mb_strlen($description_stripped, $charset) == $no_description)
{
$facebook_description = "No description provided for this product.";
}
else
{
$facebook_description = $description_stripped;
}
include_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true, )
);
// webelity.com modfied currancy and price information and added facebook_description to lower array
$attachment = array(
'access_token' => $page_token,
'message' => $new_message . " - " . $prod_name,
'name' => $prod_name,
'link' => $prod_url,
'caption' => 'Price: ' . $cur . $price,
'description' => $facebook_description,
'picture' => $prod_image
);
try {
$status = $facebook->api($page_id.'/feed', 'post', $attachment);
$messageStack->add_session('Facebook was successfully updated!', 'success');
}
catch (FacebookApiException $fbe){
$fberror = $fbe->result['error']['message'];
$messageStack->add_session('Facebook Error: '.$fberror, 'error');
}
}
so all i have done above is added
PHP Code:
if ($_POST['products_update_social_media'] == '1') {
to the start of your original autofacebook code and
to the end of your original autofacebook code.
remember the above complete code needs to be added in two sections of the ADMIN/includes/modules/update_product.php file
after
//// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////
and after
//// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////
this means the switch works on both new products and updating product
3. edit YOUR ADMIN/includes/modules/product/collect_info.php
find
PHP Code:
$parameters = array('products_name' => '',
'products_description' => '',
'products_url' => '',
'products_id' => '',
'products_quantity' => '',
'products_model' => '',
'products_image' => '',
'products_price' => '',
'products_virtual' => DEFAULT_PRODUCT_PRODUCTS_VIRTUAL,
'products_weight' => '',
'products_date_added' => '',
'products_last_modified' => '',
'products_date_available' => '',
'products_status' => '',
'products_tax_class_id' => DEFAULT_PRODUCT_TAX_CLASS_ID,
'manufacturers_id' => '',
'products_quantity_order_min' => '',
'products_quantity_order_units' => '',
'products_priced_by_attribute' => '',
'product_is_free' => '',
'product_is_call' => '',
'products_quantity_mixed' => '',
'product_is_always_free_shipping' => DEFAULT_PRODUCT_PRODUCTS_IS_ALWAYS_FREE_SHIPPING,
'products_qty_box_status' => PRODUCTS_QTY_BOX_STATUS,
'products_quantity_order_max' => '0',
'products_sort_order' => '0',
'products_discount_type' => '0',
'products_discount_type_from' => '0',
'products_price_sorter' => '0',
'master_categories_id' => ''
);
we are going to add
PHP Code:
'products_update_social_media' => '',
directly after
PHP Code:
'products_priced_by_attribute' => '',
your code should now look like
PHP Code:
$parameters = array('products_name' => '',
'products_description' => '',
'products_url' => '',
'products_id' => '',
'products_quantity' => '',
'products_model' => '',
'products_image' => '',
'products_price' => '',
'products_virtual' => DEFAULT_PRODUCT_PRODUCTS_VIRTUAL,
'products_weight' => '',
'products_date_added' => '',
'products_last_modified' => '',
'products_date_available' => '',
'products_status' => '',
'products_tax_class_id' => DEFAULT_PRODUCT_TAX_CLASS_ID,
'manufacturers_id' => '',
'products_quantity_order_min' => '',
'products_quantity_order_units' => '',
'products_priced_by_attribute' => '',
'products_update_social_media' => '',
'product_is_free' => '',
'product_is_call' => '',
'products_quantity_mixed' => '',
'product_is_always_free_shipping' => DEFAULT_PRODUCT_PRODUCTS_IS_ALWAYS_FREE_SHIPPING,
'products_qty_box_status' => PRODUCTS_QTY_BOX_STATUS,
'products_quantity_order_max' => '0',
'products_sort_order' => '0',
'products_discount_type' => '0',
'products_discount_type_from' => '0',
'products_price_sorter' => '0',
'master_categories_id' => ''
);
next find
PHP Code:
if (isset($_GET['pID']) && empty($_POST)) {
$product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
p.products_id, p.products_quantity, p.products_model,
p.products_image, p.products_price, p.products_virtual, p.products_weight,
p.products_date_added, p.products_last_modified,
date_format(p.products_date_available, '%Y-%m-%d') as
products_date_available, p.products_status, p.products_tax_class_id,
p.manufacturers_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
p.products_sort_order,
p.products_discount_type, p.products_discount_type_from,
p.products_price_sorter, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
and add
PHP Code:
p.products_update_social_media,
after
PHP Code:
p.products_priced_by_attribute,
your code should now look like this
PHP Code:
if (isset($_GET['pID']) && empty($_POST)) {
$product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
p.products_id, p.products_quantity, p.products_model,
p.products_image, p.products_price, p.products_virtual, p.products_weight,
p.products_date_added, p.products_last_modified,
date_format(p.products_date_available, '%Y-%m-%d') as
products_date_available, p.products_status, p.products_tax_class_id,
p.manufacturers_id,
p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute, p.products_update_social_media,
p.product_is_free, p.product_is_call, p.products_quantity_mixed,
p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
p.products_sort_order,
p.products_discount_type, p.products_discount_type_from,
p.products_price_sorter, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = '" . (int)$_GET['pID'] . "'
and p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
next find
PHP Code:
// Product is Priced by Attributes
if (!isset($pInfo->products_priced_by_attribute)) $pInfo->products_priced_by_attribute = '0';
switch ($pInfo->products_priced_by_attribute) {
case '0': $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true; break;
case '1': $is_products_priced_by_attribute = true; $not_products_priced_by_attribute = false; break;
default: $is_products_priced_by_attribute = false; $not_products_priced_by_attribute = true;
}
directly after add
PHP Code:
// Autofacebook
if (!isset($pInfo->products_update_social_media)) $pInfo->products_update_social_media = '0';
switch ($pInfo->products_update_social_media) {
case '0': $in_products_update_social_media = false; $out_products_update_social_media = true; break;
case '1': $in_products_update_social_media = false; $out_products_update_social_media = true; break;
default: $in_products_update_social_media = false; $out_products_update_social_media = true;
}
next find
PHP Code:
<tr>
<td class="main"><?php echo TEXT_SALEMAKER_ACTIVE; ?></td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_salemaker', '1', ($in_products_buynow_button==1)) . ' ' . TEXT_YES . ' ' . zen_draw_radio_field('products_salemaker', '0', ($in_products_salemaker==0)) . ' ' . TEXT_NO . ' ' . ($pInfo->products_salemaker == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_SALEMAKER . '</span>' : ''); ?></td>
</tr>
and add directly below
PHP Code:
<tr>
<td class="main"><?php echo TEXT_SOCIALMEDIA_ACTIVE; ?></td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_radio_field('products_update_social_media', '1', ($in_products_update_social_media==1)) . ' ' . TEXT_YES . ' ' . zen_draw_radio_field('products_update_social_media', '0', ($in_products_update_social_media==0)) . ' ' . TEXT_NO . ' ' . ($pInfo->products_update_social_media == 1 ? '<span class="errorText">' . TEXT_PRODUCTS_SOCIALMEDIA . '</span>' : ''); ?></td>
</tr>
next create a file autofacebook_switch.php
PHP Code:
<?php
/**
autofacebook switch
*/
define('TEXT_PRODUCTS_SOCIALMEDIA', '!! This has Automatically been changed to No');
define('TEXT_SOCIALMEDIA_ACTIVE', 'Facebook Upload');
upload to YOUR ADMIN/includes/languages/english/extra_definitions/
or add the two defines to your YOUR ADMIN/includes/languages/english/product.php
hopefully this is everything. please remember im not an expert on this and will help if i can but do backup first, you only need to backup database and 2 files so not a big job
hope this helps someone and if any of the experienced zenners wish to correct anything this would be much appreciated
i also created the same as the above for the autotwitter module so you have 2 switches if anyone also uses this
thanks
bn