From 2ac4e02a7ecf9a61e052b731ce8068848e3908ea Mon Sep 17 00:00:00 2001 From: gburton Date: Tue, 13 Oct 2015 11:53:07 +0100 Subject: [PATCH] Twitter Card Update from Product Card (deprecated by Twitter) to Summary or Summary Large Image --- .../header_tags/ht_twitter_product_card.php | 14 ++---- .../header_tags/ht_twitter_product_card.php | 47 ++++++------------- 2 files changed, 18 insertions(+), 43 deletions(-) diff --git a/includes/languages/english/modules/header_tags/ht_twitter_product_card.php b/includes/languages/english/modules/header_tags/ht_twitter_product_card.php index 48decacbd..1a5148836 100755 --- a/includes/languages/english/modules/header_tags/ht_twitter_product_card.php +++ b/includes/languages/english/modules/header_tags/ht_twitter_product_card.php @@ -5,17 +5,11 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2013 osCommerce + Copyright (c) 2015 osCommerce Released under the GNU General Public License */ - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TITLE', 'Twitter Product Card'); - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_DESCRIPTION', 'Add Twitter Product Card tags to your product information pages.'); - - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_PRE_ORDER', 'Pre-Order'); - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_IN_STOCK', 'In Stock'); - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_OUT_OF_STOCK', 'Out of Stock'); - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_BUY_NOW', 'BUY NOW'); - define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_CONTACT_US', 'CONTACT US'); -?> + define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TITLE', 'Twitter Card'); + define('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_DESCRIPTION', 'Add Twitter Card tags to your product information pages.'); + \ No newline at end of file diff --git a/includes/modules/header_tags/ht_twitter_product_card.php b/includes/modules/header_tags/ht_twitter_product_card.php index e3b7e3ac2..320ce9d4f 100755 --- a/includes/modules/header_tags/ht_twitter_product_card.php +++ b/includes/modules/header_tags/ht_twitter_product_card.php @@ -5,7 +5,7 @@ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com - Copyright (c) 2013 osCommerce + Copyright (c) 2015 osCommerce Released under the GNU General Public License */ @@ -31,13 +31,13 @@ function ht_twitter_product_card() { function execute() { global $PHP_SELF, $HTTP_GET_VARS, $oscTemplate, $languages_id, $currencies, $currency; - if ( ($PHP_SELF == FILENAME_PRODUCT_INFO) && isset($HTTP_GET_VARS['products_id']) ) { - $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_image, p.products_price, p.products_quantity, p.products_tax_class_id, p.products_date_available from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); + if ( ($PHP_SELF == 'product_info.php') && isset($HTTP_GET_VARS['products_id']) ) { + $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_image from products p, products_description pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ( tep_db_num_rows($product_info_query) === 1 ) { $product_info = tep_db_fetch_array($product_info_query); - $data = array('card' => 'product', + $data = array('card' => MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TYPE, 'title' => $product_info['products_name']); if ( tep_not_null(MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SITE_ID) ) { @@ -58,7 +58,7 @@ function execute() { $products_image = $product_info['products_image']; - $pi_query = tep_db_query("select image from " . TABLE_PRODUCTS_IMAGES . " where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order limit 1"); + $pi_query = tep_db_query("select image from products_images where products_id = '" . (int)$product_info['products_id'] . "' order by sort_order limit 1"); if ( tep_db_num_rows($pi_query) === 1 ) { $pi = tep_db_fetch_array($pi_query); @@ -66,27 +66,7 @@ function execute() { $products_image = $pi['image']; } - $data['image:src'] = tep_href_link(DIR_WS_IMAGES . $products_image, '', 'NONSSL', false, false); - - if ($new_price = tep_get_products_special_price($product_info['products_id'])) { - $products_price = $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])); - } else { - $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])); - } - - $data['data1'] = $products_price; - $data['label1'] = $currency; - - if ( $product_info['products_date_available'] > date('Y-m-d H:i:s') ) { - $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_PRE_ORDER; - $data['label2'] = tep_date_short($product_info['products_date_available']); - } elseif ( $product_info['products_quantity'] > 0 ) { - $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_IN_STOCK; - $data['label2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_BUY_NOW; - } else { - $data['data2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_OUT_OF_STOCK; - $data['label2'] = MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TEXT_CONTACT_US; - } + $data['image'] = tep_href_link(DIR_WS_IMAGES . $products_image, '', 'NONSSL', false, false); $result = ''; @@ -108,18 +88,19 @@ function check() { } function install() { - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Twitter Product Card Module', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_STATUS', 'True', 'Do you want to allow Twitter Product Card tags to be added to your product information pages? Note that your product images MUST be at least 160px by 160px.', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Twitter Author @username', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_USER_ID', '', 'Your @username at Twitter', '6', '0', now())"); - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Twitter Shop @username', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SITE_ID', '', 'Your shops @username at Twitter (or leave blank if it is the same as your @username above).', '6', '0', now())"); - tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); + tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Twitter Card Module', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_STATUS', 'True', 'Do you want to allow Twitter Card tags to be added to your product information pages?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); + tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Choose Twitter Card Type', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TYPE', 'summary_large_image', 'Choose Summary or Summary Large Image. Note that your product images MUST be at least h120px by w120px (Summary) or h150px x w280px (Summary Large Image).', '6', '1', 'tep_cfg_select_option(array(\'summary\', \'summary_large_image\'), ', now())"); + tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Twitter Author @username', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_USER_ID', '', 'Your @username at Twitter', '6', '0', now())"); + tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Twitter Shop @username', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SITE_ID', '', 'Your shops @username at Twitter (or leave blank if it is the same as your @username above).', '6', '0', now())"); + tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { - tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); + tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { - return array('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_STATUS', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_USER_ID', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SITE_ID', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SORT_ORDER'); + return array('MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_STATUS', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_TYPE', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_USER_ID', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SITE_ID', 'MODULE_HEADER_TAGS_TWITTER_PRODUCT_CARD_SORT_ORDER'); } } -?> + \ No newline at end of file