Forums / All Other Contributions/Addons / AutoFacebook [Support]

AutoFacebook [Support]

Views: 141,429

Results 521 to 540 of 691
24 Feb 2013, 3:19 AM
#521
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

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 :)

24 Feb 2013, 3:21 AM
#522
coopco avatar

coopco

New Zenner

Join Date:
Jun 2006
Location:
Sea Lake, Australia
Posts:
81
Plugin Contributions:
0

Re: AutoFacebook [Support]

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.

25 Feb 2013, 12:52 AM
#523
coopco avatar

coopco

New Zenner

Join Date:
Jun 2006
Location:
Sea Lake, Australia
Posts:
81
Plugin Contributions:
0

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).

1 Mar 2013, 3:05 PM
#524
jagge avatar

jagge

Zen Follower

Join Date:
Jul 2007
Posts:
110
Plugin Contributions:
0

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?

3 Mar 2013, 7:57 AM
#525
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

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

$price = substr(zen_get_products_actual_price($products_id),0,-2);

bn

3 Mar 2013, 11:14 AM
#526
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

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

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

$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

'products_update_social_media' => zen_db_prepare_input((int)$_POST['products_update_social_media']), 

below

'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

//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

//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

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

$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

'products_update_social_media' => '',

directly after

'products_priced_by_attribute' => '',

your code should now look like

$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

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

p.products_update_social_media,

after

p.products_priced_by_attribute,

your code should now look like this

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

// 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

// 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

	<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

		  <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
/**
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

5 Mar 2013, 9:00 PM
#527
pfgcomputers avatar

pfgcomputers

New Zenner

Join Date:
May 2007
Posts:
2
Plugin Contributions:
0

Re: AutoFacebook [Support]

jagge:

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?

You can have a look for a solution here:
hxxp://stackoverflow.com/questions/1890854/how-to-replace-special-characters-with-the-ones-theyre-based-on-in-php

The necessary changes needs to be made in autofacebook module only.
I would give more help than this, but i don`t have the time.
Good luck!

5 Mar 2013, 9:23 PM
#528
infogate avatar

infogate

New Zenner

Join Date:
Jun 2009
Location:
Thessaloniki, Greece
Posts:
41
Plugin Contributions:
0

Re: AutoFacebook [Support]

jagge:

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?

If you read older posts you'll find many solutions for this. I finaly converted my files and database to utf-8 and the module worked perfect with the description. :P

My Online Store thanks to Zen Cart
If everything else fails.... read the f@#$%ing manual :)
And always remember before any change!!! Backup to be able to go back!

5 Mar 2013, 9:26 PM
#529
infogate avatar

infogate

New Zenner

Join Date:
Jun 2009
Location:
Thessaloniki, Greece
Posts:
41
Plugin Contributions:
0

Re: AutoFacebook [Support]

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).

I guess you need the total price with taxes :)
Just use replace with this

//$price = $products_price;
              $price = $_POST['products_price_gross'];

My Online Store thanks to Zen Cart
If everything else fails.... read the f@#$%ing manual :)
And always remember before any change!!! Backup to be able to go back!

5 Mar 2013, 11:02 PM
#530
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

Re: AutoFacebook [Support]

Does this delay the posting to FB or does it stop it altogether?

6 Mar 2013, 6:08 AM
#531
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

joannem:

Does this delay the posting to FB or does it stop it altogether?

hi,
its just a switch so leave off when creating your product, once you finish doing what you are doing linking and metatags etc and ready to switch the product to instock while editing the product for instock also switch facebook to on, this should update your facebook,

also if you have a product on your site that you would like on facebook just edit product and switch facebook to on and this product will update to facebook

bn

6 Mar 2013, 2:38 PM
#532
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

Re: AutoFacebook [Support]

Yeah, it's not a bad idea, however, when I turn the product back on, I do it from the category list, I don't go back in to edit the product to turn it on, so this would be an extra step to take. Seems to me that there should be something in the code that could be changed or something added, so that it would automatically send it to FB when I activate it.

I just Jamie isn't checking this thread anymore, it's sad, because it's a really good mod, just needs a little improvement :(

6 Mar 2013, 10:52 PM
#533
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

joannem:

Yeah, it's not a bad idea, however, when I turn the product back on, I do it from the category list, I don't go back in to edit the product to turn it on, so this would be an extra step to take. Seems to me that there should be something in the code that could be changed or something added, so that it would automatically send it to FB when I activate it.

I just Jamie isn't checking this thread anymore, it's sad, because it's a really good mod, just needs a little improvement :(

so every time you switch an item active it updates facebook with that product ?

is this what you are looking

bn

6 Mar 2013, 11:40 PM
#534
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

Re: AutoFacebook [Support]

That is EXACTLY what I'm looking for yayyyy someone understands me lol

I think it's in the categories.php file - it looks up the status of the product - now if there's a way to put that in with the auto FB code that would be awesome :)

        // change the status of categories and products
        zen_set_time_limit(600);
        for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
          if ($_POST['categories_status'] == '1') {
            $categories_status = '0';
            $products_status = '0';
          } else {
            $categories_status = '1';
            $products_status = '1';
          }
7 Mar 2013, 8:40 PM
#535
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

hi,

this might work for you,

in your admin/categories.php around line 109

change

      case 'setflag':

      if ( isset($_POST['flag']) && ($_POST['flag'] == '0') || ($_POST['flag'] == '1') ) {
        if (isset($_GET['pID'])) {
          zen_set_product_status($_GET['pID'], $_POST['flag']);
        }
      }

to

case 'setflag':

      if ( isset($_POST['flag']) && ($_POST['flag'] == '0') || ($_POST['flag'] == '1') ) {
        if (isset($_GET['pID'])) {
          zen_set_product_status($_GET['pID'], $_POST['flag']);
        }
		if ($_POST['flag'] == '1') {
		if (empty($language)) $language = $_SESSION['languages_id'];
		$products_id = $_GET['pID'];

$product_lookup = $db->Execute("select pd.products_name, p.products_image, pd.products_description, pc.categories_id
                              from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " pc
                              where  p.products_id ='" . $products_id . "'
                              and pd.products_id = p.products_id
                              and pd.language_id = '1'");

    //$return_field = $product_lookup->fields['lookup_field'];

    //return $return_field;
	$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/" . $product_lookup->fields['products_image'];
          $price = substr(zen_get_products_actual_price($products_id),0,-2);
          $prod_url = $store_url . '/index.php?main_page=product_info&cPath=' . $product_lookup->fields['categories_id'] . '&products_id=' . $products_id;
          $prod_name = $product_lookup->fields['products_name'];
          //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 = $product_lookup->fields['products_description'];

          //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 './includes/modules/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');
          }
		}
      }

obviously adding your info to this code

bn

7 Mar 2013, 11:09 PM
#536
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

Re: AutoFacebook [Support]

It didn't work :(

Well first it was because the folders had to be in the same directory as the categories.php file, as they did in the updateproduct.php folder.

But then it didn't get posted to Facebook, and the red icon wouldn't change to green either :(

Thank you SO much for trying for me though, I really appreciate it :)

8 Mar 2013, 6:59 AM
#537
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: AutoFacebook [Support]

not sure whats not right, on the test site i used the above code it seems to be working fine, test site is v1.51

bn

8 Mar 2013, 5:22 PM
#538
phil_lomas avatar

phil_lomas

New Zenner

Join Date:
Feb 2013
Location:
Southampton, United Kingdom
Posts:
40
Plugin Contributions:
0

Re: AutoFacebook [Support]

Hi.
I have installed this and when I put a new item on zencart the message appears saying it has posted to facebook but nothing appears. site is https://www.bikeporn.co.uk and facebook page is http://www.facebook.com/pages/Bikeporncouk/166983630118189. If anyone has any ideas as to why it's not working would really appreciate some input. Guess I am probably doing something silly but cannot work out what.

Thanks in advance

Phil

8 Mar 2013, 6:01 PM
#539
joannem avatar

joannem

Zen Follower

Join Date:
Jul 2009
Posts:
110
Plugin Contributions:
0

Re: AutoFacebook [Support]

I have an older version of zen cart installed, that's probably why :( I'm gonna update it but not sure when

10 Mar 2013, 12:25 PM
#540
coopco avatar

coopco

New Zenner

Join Date:
Jun 2006
Location:
Sea Lake, Australia
Posts:
81
Plugin Contributions:
0

Re: AutoFacebook [Support]

bn17311:

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

$price = substr(zen_get_products_actual_price($products_id),0,-2);

> 
> bn

Thanks bn17311

That worked.