ShareYourCart + integration tweaks

This commit is contained in:
Mike Jolley 2012-04-30 20:50:35 +01:00
parent 911ae3dd71
commit 62c1d9d15c
49 changed files with 1353 additions and 562 deletions

View File

@ -1101,75 +1101,6 @@ $woocommerce_settings['email'] = apply_filters('woocommerce_email_settings', arr
)); // End email settings
$woocommerce_settings['integration'] = apply_filters('woocommerce_intregation_settings', array(
array( 'name' => __( 'ShareThis', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareThis offers a sharing widget which will allow customers to share links to products with their friends.', 'woocommerce'), 'id' => 'share_this' ),
array(
'name' => __( 'ShareThis Publisher ID', 'woocommerce' ),
'desc' => sprintf( __( 'Enter your %1$sShareThis publisher ID%2$s to show social sharing buttons on product pages.', 'woocommerce' ), '<a href="http://sharethis.com/account/">', '</a>' ),
'id' => 'woocommerce_sharethis',
'type' => 'text',
'std' => '',
'css' => 'min-width:300px;',
),
array( 'type' => 'sectionend', 'id' => 'share_this'),
array( 'name' => __( 'ShareDaddy', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareDaddy is a sharing plugin bundled with JetPack.', 'woocommerce'), 'id' => 'sharedaddy' ),
array(
'name' => __( 'Output ShareDaddy button?', 'woocommerce' ),
'desc' => __( 'Enable this option to show the ShareDaddy button (if installed) on the product page.', 'woocommerce' ),
'id' => 'woocommerce_sharedaddy',
'type' => 'checkbox',
'std' => 'no',
),
array( 'type' => 'sectionend', 'id' => 'sharedaddy'),
array( 'name' => __( 'ShareYourCart', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareYourCart helps you get more customers by motivating satisfied customers to talk with their friends about your products.', 'woocommerce'), 'id' => 'shareyourcart' ),
array(
'name' => __( 'ShareYourCart integration', 'woocommerce' ),
'desc' => __( 'Enable this option to enable ShareYourCart', 'woocommerce' ),
'id' => 'woocommerce_shareyourcart',
'type' => 'checkbox',
'std' => 'no',
),
array( 'type' => 'sectionend', 'id' => 'shareyourcart'),
array( 'name' => __( 'Google Analytics', 'woocommerce' ), 'type' => 'title', 'desc' => __('Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website.', 'woocommerce'), 'id' => 'google_analytics' ),
array(
'name' => __('Google Analytics ID', 'woocommerce'),
'desc' => __('Log into your google analytics account to find your ID. e.g. <code>UA-XXXXX-X</code>', 'woocommerce'),
'id' => 'woocommerce_ga_id',
'type' => 'text',
'css' => 'min-width:300px;',
),
array(
'name' => __('Tracking code', 'woocommerce'),
'desc' => __('Add tracking code to your site\'s footer. You don\'t need to enable this if using a 3rd party analytics plugin.', 'woocommerce'),
'id' => 'woocommerce_ga_standard_tracking_enabled',
'type' => 'checkbox',
'checkboxgroup' => 'start'
),
array(
'name' => __('Tracking code', 'woocommerce'),
'desc' => __('Add eCommerce tracking code to the thankyou page', 'woocommerce'),
'id' => 'woocommerce_ga_ecommerce_tracking_enabled',
'type' => 'checkbox',
'checkboxgroup' => 'end'
),
array( 'type' => 'sectionend', 'id' => 'google_analytics'),
)); // End integration settings
/**
* Settings page
*
@ -1179,11 +1110,12 @@ if (!function_exists('woocommerce_settings')) {
function woocommerce_settings() {
global $woocommerce, $woocommerce_settings;
$current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : urldecode( $_GET['tab'] );
$current_section = ( empty( $_GET['section'] ) ) ? '' : urldecode( $_GET['section'] );
$current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : urldecode( $_GET['tab'] );
$current_section = ( empty( $_REQUEST['section'] ) ) ? '' : urldecode( $_REQUEST['section'] );
// Save settings
if ( ! empty( $_POST ) ) {
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-settings' ) )
die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
@ -1197,7 +1129,6 @@ function woocommerce_settings() {
case "shipping" :
case "tax" :
case "email" :
case "integration" :
woocommerce_update_options( $woocommerce_settings[$current_tab] );
break;
}
@ -1225,13 +1156,28 @@ function woocommerce_settings() {
wp_redirect( $redirect );
exit;
}
// Settings saved message
// Get any returned messages
$error = ( empty( $_GET['wc_error'] ) ) ? '' : urldecode( stripslashes( $_GET['wc_error'] ) );
$message = ( empty( $_GET['wc_message'] ) ) ? '' : urldecode( stripslashes( $_GET['wc_message'] ) );
if ( $error || $message ) {
if ( $error ) {
echo '<div id="message" class="error fade"><p><strong>' . wptexturize( $error ) . '</strong></p></div>';
} else {
echo '<div id="message" class="updated fade"><p><strong>' . wptexturize( $message ) . '</strong></p></div>';
}
} elseif ( ! empty( $_GET['saved'] ) ) {
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your settings have been saved.', 'woocommerce' ) . '</strong></p></div>';
}
// Were the settings saved?
if ( ! empty( $_GET['saved'] ) ) {
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your settings have been saved.', 'woocommerce' ) . '</strong></p></div>';
flush_rewrite_rules( false );
do_action('woocommerce_settings_saved');
}
@ -1317,7 +1263,6 @@ function woocommerce_settings() {
case "inventory" :
case "tax" :
case "email" :
case "integration" :
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
break;
case "shipping" :
@ -1460,6 +1405,25 @@ function woocommerce_settings() {
echo '</div>';
break;
case "integration" :
$integrations = $woocommerce->integrations->get_integrations();
$section = empty( $_GET['section'] ) ? key( $integrations ) : urldecode( $_GET['section'] );
foreach ( $integrations as $integration ) {
$title = ( isset( $integration->method_title ) && $integration->method_title) ? ucwords( $integration->method_title ) : ucwords( $method->id );
$current = ( $integration->id == $section ) ? 'class="current"' : '';
$links[] = '<a href="' . add_query_arg( 'section', $integration->id, admin_url('admin.php?page=woocommerce&tab=integration') ) . '"' . $current . '>' . $title . '</a>';
}
echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />';
if ( isset( $integrations[ $section ] ) )
$integrations[ $section ]->admin_options();
break;
default :
do_action( 'woocommerce_settings_tabs_' . $current_tab );

File diff suppressed because one or more lines are too long

View File

@ -110,6 +110,12 @@
}
}
#wc_get_started { position: relative; margin: 1em 0 2em; padding: 15px 15px 15px 90px; border: 1px solid #d9d9d9; background: #f5f5f5 url(../images/gear.png) no-repeat 15px 15px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -moz-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -webkit-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; }
#wc_get_started span { display: block; text-shadow: 1px 1px 0 #fff; font-size: 14px; line-height: 22px; color: #595959; }
#wc_get_started span.main { margin-top: 2px; font-weight: bold; font-size: 16px; }
#wc_get_started .main-button { position: absolute; right: 20px; top: 27px; }
#wc_get_started p { margin: 1em 0 .5em; }
#icon-woocommerce, .woocommerce_icon, .icon32-posts-product, .icon32-posts-shop_order, .icon32-posts-shop_coupon, .icon32-posts-product_variation {
background-image: url(../images/icons/woocommerce-icons.png) !important;
background-position: -11px -6px;

BIN
assets/images/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

View File

@ -0,0 +1,38 @@
<?php
/**
* WooCommerce Integration class
*
* Extended by individual integrations to offer additional functionality.
*
* @class WC_Integration
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_Integration extends WC_Settings_API {
/**
* Admin Options
*
* Setup the gateway settings screen.
* Override this in your gateway.
*
* @since 1.0.0
*/
function admin_options() { ?>
<h3><?php echo isset( $this->method_title ) ? $this->method_title : __( 'Settings', 'woocommerce' ) ; ?></h3>
<?php echo isset( $this->method_description ) ? wpautop( $this->method_description ) : ''; ?>
<table class="form-table">
<?php $this->generate_settings_html(); ?>
</table>
<!-- Section -->
<div><input type="hidden" name="section" value="<?php echo $this->id; ?>" /></div>
<?php
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* WooCommerce Integrations class
*
* Loads Integrations into WooCommerce.
*
* @class WC_Integrations
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_Integrations {
var $integrations = array();
/**
* init function.
*
* @access public
*/
function init() {
do_action('woocommerce_integrations_init');
$load_integrations = apply_filters('woocommerce_integrations', array() );
// Load integration classes
foreach ( $load_integrations as $integration ) {
$load_integration = new $integration();
$this->integrations[$load_integration->id] = $load_integration;
}
}
function get_integrations() {
return $this->integrations;
}
}

View File

@ -0,0 +1,204 @@
<?php
/**
* Google Analytics Integration
*
* Allows tracking code to be inserted into store pages.
*
* @class WC_Google_Analytics
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_Google_Analytics extends WC_Integration {
public function __construct() {
$this->id = 'google_analytics';
$this->method_title = __( 'Google Analytics', 'woocommerce' );
$this->method_description = __( 'Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website.', 'woocommerce' );
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Define user set variables
$this->ga_id = $this->settings['ga_id'];
$this->ga_standard_tracking_enabled = $this->settings['ga_standard_tracking_enabled'];
$this->ga_ecommerce_tracking_enabled = $this->settings['ga_ecommerce_tracking_enabled'];
// Actions
add_action( 'woocommerce_update_options_integration_google_analytics', array( &$this, 'process_admin_options') );
// Tracking code
add_action( 'wp_footer', array( &$this, 'google_tracking_code' ) );
add_action( 'woocommerce_thankyou', array( &$this, 'ecommerce_tracking_code' ) );
}
/**
* Initialise Settings Form Fields
*/
function init_form_fields() {
$this->form_fields = array(
'ga_id' => array(
'title' => __('Google Analytics ID', 'woocommerce'),
'description' => __('Log into your google analytics account to find your ID. e.g. <code>UA-XXXXX-X</code>', 'woocommerce'),
'type' => 'text',
'default' => get_option('woocommerce_ga_id')
),
'ga_standard_tracking_enabled' => array(
'title' => __('Tracking code', 'woocommerce'),
'label' => __('Add tracking code to your site\'s footer. You don\'t need to enable this if using a 3rd party analytics plugin.', 'woocommerce'),
'type' => 'checkbox',
'checkboxgroup' => 'start',
'default' => get_option('woocommerce_ga_standard_tracking_enabled') ? get_option('woocommerce_ga_standard_tracking_enabled') : 'no'
),
'ga_ecommerce_tracking_enabled' => array(
'label' => __('Add eCommerce tracking code to the thankyou page', 'woocommerce'),
'type' => 'checkbox',
'checkboxgroup' => 'end',
'default' => get_option('woocommerce_ga_ecommerce_tracking_enabled') ? get_option('woocommerce_ga_ecommerce_tracking_enabled') : 'no'
)
);
/**
* Google Analytics standard tracking
**/
function google_tracking_code() {
global $woocommerce;
if ( is_admin() || current_user_can('manage_options') || get_option('woocommerce_ga_standard_tracking_enabled') == "no" ) return;
$tracking_id = get_option('woocommerce_ga_id');
if ( ! $tracking_id ) return;
$loggedin = ( is_user_logged_in() ) ? 'yes' : 'no';
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
$current_user = get_user_by('id', $user_id);
$username = $current_user->user_login;
} else {
$user_id = '';
$username = __('Guest', 'woocommerce');
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', '<?php echo $tracking_id; ?>'],
['_setCustomVar', 1, 'logged-in', '<?php echo $loggedin; ?>', 1],
['_setCustomVar', 2, 'user-id', '<?php echo $user_id; ?>', 1],
['_setCustomVar', 3, 'username', '<?php echo $username; ?>', 1],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
/**
* Google Analytics eCommerce tracking
**/
function ecommerce_tracking_code( $order_id ) {
global $woocommerce;
if ( is_admin() || current_user_can('manage_options') || get_option('woocommerce_ga_ecommerce_tracking_enabled') == "no" ) return;
$tracking_id = get_option('woocommerce_ga_id');
if ( ! $tracking_id ) return;
// Doing eCommerce tracking so unhook standard tracking from the footer
remove_action('wp_footer', 'woocommerce_google_tracking');
// Get the order and output tracking code
$order = new WC_Order($order_id);
$loggedin = (is_user_logged_in()) ? 'yes' : 'no';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$current_user = get_user_by('id', $user_id);
$username = $current_user->user_login;
} else {
$user_id = '';
$username = __('Guest', 'woocommerce');
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', '<?php echo $tracking_id; ?>'],
['_setCustomVar', 1, 'logged-in', '<?php echo $loggedin; ?>', 1],
['_setCustomVar', 2, 'user-id', '<?php echo $user_id; ?>', 1],
['_setCustomVar', 3, 'username', '<?php echo $username; ?>', 1],
['_trackPageview']
);
_gaq.push(['_addTrans',
'<?php echo $order_id; ?>', // order ID - required
'<?php bloginfo('name'); ?>', // affiliation or store name
'<?php echo $order->order_total; ?>', // total - required
'<?php echo $order->get_total_tax(); ?>', // tax
'<?php echo $order->get_shipping(); ?>', // shipping
'<?php echo $order->billing_city; ?>', // city
'<?php echo $order->billing_state; ?>', // state or province
'<?php echo $order->billing_country; ?>' // country
]);
// Order items
<?php if ($order->get_items()) foreach($order->get_items() as $item) : $_product = $order->get_product_from_item( $item ); ?>
_gaq.push(['_addItem',
'<?php echo $order_id; ?>', // order ID - required
'<?php if (!empty($_product->sku))
echo __('SKU:', 'woocommerce') . ' ' . $_product->sku;
else
echo $_product->id;
?>', // SKU/code - required
'<?php echo $item['name']; ?>', // product name
'<?php if (isset($_product->variation_data)){
echo woocommerce_get_formatted_variation( $_product->variation_data, true );
} else {
$out = array();
$categories = get_the_terms($_product->id, 'product_cat');
foreach ( $categories as $category ){
$out[] = $category->name;
}
echo join( "/", $out);
}
?>', // category or variation
'<?php echo ($item['line_total']/$item['qty']); ?>', // unit price - required
'<?php echo $item['qty']; ?>' // quantity - required
]);
<?php endforeach; ?>
_gaq.push(['_trackTrans']); // submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
} // End init_form_fields()
}
/**
* Add the integration to WooCommerce
**/
function add_google_analytics_integration( $integrations ) {
$integrations[] = 'WC_Google_Analytics'; return $integrations;
}
add_filter('woocommerce_integrations', 'add_google_analytics_integration' );

View File

@ -0,0 +1,76 @@
<?php
/**
* ShareDaddy Integration
*
* Enables ShareDaddy integration.
*
* @class WC_ShareThis
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_ShareDaddy extends WC_Integration {
public function __construct() {
$this->id = 'sharedaddy';
$this->method_title = __( 'ShareDaddy', 'woocommerce' );
$this->method_description = __( 'ShareDaddy is a sharing plugin bundled with JetPack.', 'woocommerce' );
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Define user set variables
$this->enabled = $this->settings['enabled'];
// Actions
add_action( 'woocommerce_update_options_integration_sharedaddy', array( &$this, 'process_admin_options') );
// Share widget
add_action( 'woocommerce_share', array( &$this, 'sharedaddy_code') );
}
/**
* Initialise Settings Form Fields
*/
function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Output ShareDaddy button?', 'woocommerce' ),
'description' => __( 'Enable this option to show the ShareDaddy button on the product page.', 'woocommerce' ),
'type' => 'checkbox',
'default' => get_option('woocommerce_sharedaddy') ? get_option('woocommerce_sharedaddy') : 'no'
)
);
} // End init_form_fields()
/**
* sharedaddy_code function.
*
*/
function sharedaddy_code() {
global $post;
if ( $this->enabled == 'yes' && function_exists('sharing_display') ) {
?><div class="social"><?php echo sharing_display(); ?></div><?php
}
}
}
/**
* Add the integration to WooCommerce
**/
function add_sharedaddy_integration( $integrations ) {
if ( class_exists('jetpack') )
$integrations[] = 'WC_ShareDaddy';
return $integrations;
}
add_filter('woocommerce_integrations', 'add_sharedaddy_integration' );

View File

@ -0,0 +1,95 @@
<?php
/**
* ShareThis Integration
*
* Enables ShareThis integration.
*
* @class WC_ShareThis
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_ShareThis extends WC_Integration {
var $default_code;
public function __construct() {
$this->id = 'sharethis';
$this->method_title = __( 'ShareThis', 'woocommerce' );
$this->method_description = __( 'ShareThis offers a sharing widget which will allow customers to share links to products with their friends.', 'woocommerce' );
$this->default_code = '<div class="social">
<iframe src="https://www.facebook.com/plugins/like.php?href={permalink}&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis"></span><span class="st_plusone_button"></span>
</div>';
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Define user set variables
$this->publisher_id = $this->settings['publisher_id'];
$this->sharethis_code = $this->settings['sharethis_code'];
if ( ! $this->sharethis_code ) $this->sharethis_code = $this->default_code;
// Actions
add_action( 'woocommerce_update_options_integration_sharethis', array( &$this, 'process_admin_options') );
// Share widget
add_action( 'woocommerce_share', array( &$this, 'sharethis_code') );
}
/**
* Initialise Settings Form Fields
*/
function init_form_fields() {
$this->form_fields = array(
'publisher_id' => array(
'title' => __( 'ShareThis Publisher ID', 'woocommerce' ),
'description' => sprintf( __( 'Enter your %1$sShareThis publisher ID%2$s to show social sharing buttons on product pages.', 'woocommerce' ), '<a href="http://sharethis.com/account/">', '</a>' ),
'type' => 'text',
'default' => get_option('woocommerce_sharethis')
),
'sharethis_code' => array(
'title' => __( 'ShareThis Code', 'woocommerce' ),
'description' => __( 'You can tweak the ShareThis code by editing this option.', 'woocommerce' ),
'type' => 'textarea',
'default' => $this->default_code
)
);
} // End init_form_fields()
/**
* sharethis_code function.
*
*/
function sharethis_code() {
global $post;
if ( $this->publisher_id ) {
$sharethis = ( is_ssl() ) ? 'https://ws.sharethis.com/button/buttons.js' : 'http://w.sharethis.com/button/buttons.js';
echo str_replace( '{permalink}', urlencode(get_permalink($post->ID)), $this->sharethis_code );
echo '<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="' . $sharethis . '"></script>';
echo '<script type="text/javascript">stLight.options({publisher:"' . $this->publisher_id . '"});</script>';
}
}
}
/**
* Add the integration to WooCommerce
**/
function add_sharethis_integration( $integrations ) {
$integrations[] = 'WC_ShareThis'; return $integrations;
}
add_filter('woocommerce_integrations', 'add_sharethis_integration' );

View File

@ -0,0 +1,383 @@
<?php
require_once "sdk/class.shareyourcart-base.php";
class ShareYourCartWooCommerce extends ShareYourCartBase {
public $settings;
public $_plugin_name = "shareyourcart_woo_commerce";
public $_post_user_id = 1;
protected static $_VERSION = 1;
/**
* Constructor
* @param null
*/
function __construct( $settings ) {
$this->settings = $settings;
parent::__construct();
//if there is installed another plugin with a never version
//do not load this one further
if (!$this->canLoad()) return;
// Shortcodes
add_shortcode( 'shareyourcart', array(&$this, 'getButton') );
add_shortcode( 'shareyourcart_button', array(&$this, 'getButton') );
// Actions
add_action( 'init', array(&$this, 'init') );
add_action( 'wp', array(&$this, 'hook_buttons') );
add_action( 'wp_head', array(&$this, 'wp_head') );
}
function admin_settings_page() {
$this->checkSDKStatus(true);
}
/**
* processInit function.
*
* @access public
*/
public function init() {
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case $this->_plugin_name:
$this->buttonCallback();
break;
case $this->_plugin_name . '_coupon':
$this->couponCallback();
break;
}
}
}
/**
* hook_buttons function.
*
* @access public
*/
public function hook_buttons() {
if ( $this->isSingleProduct() )
add_filter('woocommerce_product_description_heading', array(&$this, '_getProductButton'));
add_action('woocommerce_cart_coupon', array(&$this, '_getCartButton'));
}
public function wp_head() {
echo '<meta property="syc:client_id" content="' . $this->getClientId() . '" />';
}
public function _getProductButton( $title ) {
$title .= $this->getProductButton();
return $title;
}
public function _getCartButton() {
echo '<div id="shareyourcart_button">' . $this->getCartButton() . '</div>';
}
public function getSecretKey() {
return '2cfd496d-7812-44ba-91ce-e43c59f6c680';
}
public function isSingleProduct() {
return is_singular('product');
}
public function saveCoupon( $token, $coupon_code, $coupon_value, $coupon_type ) {
// Create coupon
$post_id = $this->_saveCouponPost($coupon_code);
// Set coupon meta
switch ($coupon_type) {
case 'amount':
$discount_type = 'fixed_product';
$free_shipping = 'no';
break;
case 'percent':
$discount_type = 'percent_product';
$free_shipping = 'no';
break;
case 'free_shipping':
$discount_type = 'fixed_product';
$coupon_value = 0;
$free_shipping = 'yes';
break;
default :
$discount_type = 'fixed_cart';
$free_shipping = 'no';
}
update_post_meta( $post_id, 'customer_email', array() );
update_post_meta( $post_id, 'minimum_amount', '' );
update_post_meta( $post_id, 'exclude_product_categories', array() );
update_post_meta( $post_id, 'product_categories', array() );
update_post_meta( $post_id, 'free_shipping', $free_shipping );
update_post_meta( $post_id, 'apply_before_tax', 'yes' );
update_post_meta( $post_id, 'expiry_date', '' );
update_post_meta( $post_id, 'usage_limit', 1 );
update_post_meta( $post_id, 'exclude_product_ids', '' );
update_post_meta( $post_id, 'product_ids', '' );
update_post_meta( $post_id, 'individual_use', 'yes' );
update_post_meta( $post_id, 'coupon_amount', $coupon_value );
update_post_meta( $post_id, 'discount_type', $discount_type );
// parent
parent::saveCoupon( $token, $coupon_code, $coupon_value, $coupon_type );
}
public function applyCoupon( $coupon_code ) {}
private function _saveCouponPost($coupon_code) {
$new_post = array(
'post_title' => $coupon_code,
'post_name' => ereg_replace("[^A-Za-z0-9]", "", $coupon_code),
'post_content' => '',
'post_status' => 'publish',
'comment_status'=> 'closed',
'ping_status' => 'closed',
'post_author' => $this->_post_user_id,
'post_type' => 'shop_coupon'
);
$post_id = wp_insert_post($new_post);
return $post_id;
}
public function getButtonCallbackURL() {
global $wp_query;
$callback_url = add_query_arg( 'action', $this->_plugin_name, trailingslashit( home_url() ) );
if ($this->isSingleProduct()) {
$callback_url .= '&p='. $wp_query->post->ID;
}
return $callback_url;
}
public function buttonCallback() {
//specify the parameters
$params = array(
'callback_url' => get_bloginfo('wpurl').'/?action='.$this->_plugin_name.'_coupon'.(isset($_REQUEST['p']) ? '&p='.$_REQUEST['p'] : '' ),
'success_url' => get_option('shopping_cart_url'),
'cancel_url' => get_option('shopping_cart_url'),
);
//there is no product set, thus send the products from the shopping cart
if (!isset($_REQUEST['p'])) {
if (empty($_SESSION['cart']))
exit("Cart is empty");
foreach ($_SESSION['cart'] as $cart_details) {
$params['cart'][] = $this->_getProductDetails($cart_details['product_id']);
}
}
else {
$params['cart'][] = $this->_getProductDetails($_GET['p']);
}
try
{
$this->startSession($params);
}
catch(Exception $e) {
//display the error to the user
echo $e->getMessage();
}
exit;
}
private function _getProductDetails($product_id) {
$product = new WC_Product($product_id);
ob_start();
$product->get_image();
$image = ob_get_clean();
return array(
"item_name" => $product->get_title(),
"item_description" => $product->post->post_content,
"item_url" => $product->post->guid,
"item_price" => $product->price,
"item_picture_url" => $image,
);
}
public function loadSessionData() {
return;
}
/**
*
* Get the plugin version.
* @return an integer
*
*/
protected function getPluginVersion() {
return self::$_VERSION;
}
/**
*
* Return the project's URL
*
*/
protected function getDomain() {
return get_bloginfo('url');
}
/**
*
* Return the admin's email
*
*/
protected function getAdminEmail() {
return get_settings('admin_email');
}
/**
*
* Set the field value
*
*/
public function setConfigValue($field, $value) {
$this->settings[$field] = $value;
update_option( 'woocommerce_shareyourcart_settings', $this->settings );
}
/**
*
* Get the field value
*
*/
protected function getConfigValue( $field ) {
switch ( $field ) {
case "clientId" :
return $this->settings['client_id'];
case "hide_on_checkout" :
return ( $this->settings['show_on_cart'] == 'yes' ) ? false : true;
case "hide_on_product" :
return ( $this->settings['show_on_product'] == 'yes' ) ? false : true;
case "appKey" :
return $this->settings['app_key'];
case "account_status" :
return 'active';
case "button_type" :
if ( $this->settings['button_style'] == 'image_button' ) return 2;
if ( $this->settings['button_style'] == 'custom_html' ) return 3;
return 1; // Standard
break;
default :
return ( isset( $this->settings[$field] ) ) ? $this->settings[$field] : '';
}
}
/**
*
* Execute the SQL statement
*
*/
protected function executeNonQuery($sql) {
if (substr($sql, 0, 12) == "CREATE TABLE") {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
//if this is a create table command, use the special function which compares tables
dbDelta($sql);
} else {
global $wpdb;
//use the normal query
$wpdb->query($sql);
}
}
/**
*
* Get the row returned from the SQL
*
* @return an associative array containing the data of the row OR NULL
* if there is none
*/
protected function getRow($sql) {
global $wpdb;
//get the row as an associative array
return $wpdb->get_row($sql, ARRAY_A);
}
/**
*
* Get the table name based on the key
*
*/
protected function getTableName($key) {
global $wpdb;
return $wpdb->base_prefix . $key;
}
/**
*
* Insert the row into the specified table
*
*/
protected function insertRow($tableName, $data) {
global $wpdb;
$wpdb->insert($tableName, $data);
}
/**
*
* Create url for the specified file. The file must be specified in relative path
* to the base of the plugin
*/
protected function createUrl($file) {
//get the real file path
$file = realpath($file);
//calculate the relative path from this file
$file = SyC::relativepath(dirname(__FILE__), $file);
//append the relative path to the current file's URL
return WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__), "", plugin_basename(__FILE__)).$file;
}
/*
*
* Called when a new coupon is generated
*
*/
public function couponCallback() {
parent::couponCallback();
//since this is actually an API, exit
exit;
}
}

View File

@ -0,0 +1,373 @@
<?php
/**
* ShareYourCart Integration
*
* Enables ShareYourCart integration.
*
* @class WC_ShareYourCart
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_ShareYourCart extends WC_Integration {
var $ShareYourCartWooCommerce;
public function __construct() {
$this->id = 'shareyourcart';
$this->method_title = __( 'ShareYourCart', 'woocommerce' );
$this->method_description = sprintf( __( 'Increase your social media exposure by 10 percent! ShareYourCart helps you get more customers by motivating satisfied customers to talk with their friends about your products. For help with ShareYourCart view the <a href="%s">documentation</a>.', 'woocommerce' ), 'http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/' );
// Load the form fields.
$this->init_form_fields();
// Load the settings.
$this->init_settings();
// Define user set variables
$this->enabled = $this->settings['enabled'];
$this->client_id = $this->settings['client_id'];
$this->app_key = $this->settings['app_key'];
$this->email = $this->settings['email'];
// Actions
add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_admin_options') );
add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_forms') );
// Actions if enabled
if ( $this->enabled == 'yes' ) {
add_action( 'wp_enqueue_scripts', array(&$this, 'styles') );
// Share your cart api class
include_once('class-shareyourcart-woocommerce.php');
// Init the class
$this->shareYourCartWooCommerce = new ShareYourCartWooCommerce( $this->settings );
}
}
/**
* styles function.
*
* @access public
* @return void
*/
public function styles() {
wp_enqueue_style( 'shareyourcart', plugins_url( 'css/style.css', __FILE__ ) );
}
/**
* process_forms function.
*
* @access public
*/
function process_forms() {
if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) {
$error = $message = '';
$redirect = remove_query_arg( 'saved' );
$redirect = remove_query_arg( 'wc_error', $redirect );
$redirect = remove_query_arg( 'wc_message', $redirect );
if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) && ! empty( $_POST['syc-terms-agreement'] ) ) {
if ( ! ( ( $register = $this->shareYourCartWooCommerce->register( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) === false) ) {
$this->shareYourCartWooCommerce->setConfigValue('app_key', $register['app_key']);
$this->shareYourCartWooCommerce->setConfigValue('client_id', $register['client_id']);
$redirect = remove_query_arg( 'syc-account', $redirect );
} else {
$error = $message;
if ( json_decode($error) ) {
$error = json_decode($error);
$error = $error->message;
}
$message = '';
}
} else {
$error = __( 'Please complete all fields.', 'woocommerce' );
}
if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect );
if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect );
wp_safe_redirect( $redirect );
exit;
} elseif ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'recover' ) {
$error = $message = '';
$redirect = remove_query_arg( 'saved' );
$redirect = remove_query_arg( 'wc_error', $redirect );
$redirect = remove_query_arg( 'wc_message', $redirect );
if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) ) {
if ( ! $this->shareYourCartWooCommerce->recover( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) {
$error = $message;
if ( json_decode($error) ) {
$error = json_decode($error);
$error = $error->message;
}
$message = '';
} else {
$redirect = remove_query_arg( 'syc-account', $redirect );
}
} else {
$error = __( 'Please complete all fields.', 'woocommerce' );
}
if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect );
if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect );
wp_safe_redirect( $redirect );
exit;
}
}
/**
* Admin Options
*
* Setup the gateway settings screen.
* Override this in your gateway.
*
* @since 1.0.0
*/
function admin_options() {
if ( $this->enabled == 'yes' ) {
// Installation
$this->shareYourCartWooCommerce->install();
// Check status
$this->shareYourCartWooCommerce->admin_settings_page();
}
?>
<?php
if ( ! $this->client_id && ! $this->app_key ) {
if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) {
?>
<div class="updated">
<h3><?php _e('Create a ShareYourCart account', 'woocommerce') ?></h3>
<table class="form-table">
<tr>
<th><?php _e('Domain', 'woocommerce'); ?></th>
<td><input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : site_url()); ?>" /></td>
</tr>
<tr>
<th><?php _e('Email', 'woocommerce'); ?></th>
<td><input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : get_option('admin_email')); ?>"/></td>
</tr>
<tr>
<th>&nbsp;</th>
<td><input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" type="checkbox" /> <label for="syc-terms-agreement"><?php printf(__('I agree to the <a href="%s">ShareYourCart terms and conditions</a>', 'woocommerce'), 'http://shareyourcart.com/terms'); ?></label></td>
</tr>
</table>
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e('Create Account', 'woocommerce') ?>" /></p>
</div>
<?php
} elseif ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'recover' ) {
?>
<div class="updated">
<h3><?php _e('Recover your ShareYourCart account', 'woocommerce') ?></h3>
<table class="form-table">
<tr>
<th><?php _e('Domain', 'woocommerce'); ?></th>
<td><input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : site_url()); ?>" /></td>
</tr>
<tr>
<th><?php _e('Email', 'woocommerce'); ?></th>
<td><input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : get_option('admin_email')); ?>"/></td>
</tr>
</table>
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e('Email me my details', 'woocommerce') ?>" /></p>
</div>
<?php
} else {
?>
<div id="wc_get_started">
<span class="main"><?php _e('Setup your ShareYourCart account', 'woocommerce'); ?></span>
<span><?php echo $this->method_description; ?></span>
<p><a href="<?php echo add_query_arg( 'syc-account', 'create', admin_url( 'admin.php?page=woocommerce&tab=integration&section=shareyourcart' ) ); ?>" class="button button-primary api-link"><?php _e('Create an account', 'woocommerce'); ?></a> <a href="<?php echo add_query_arg( 'syc-account', 'recover', admin_url( 'admin.php?page=woocommerce&tab=integration&section=shareyourcart' ) ); ?>" class="button api-link"><?php _e('Can\'t access your account?', 'woocommerce'); ?></a></p>
</div>
<?php
}
} else {
echo '<h3><a href="http://shareyourcart.com/"><img src="' . plugins_url( 'sdk/img/shareyourcart-logo.png', __FILE__ ) . '" alt="ShareYourCart" /></a></h3>';
echo wpautop( $this->method_description );
}
?>
<table class="form-table">
<?php $this->generate_settings_html(); ?>
<?php if ( $this->client_id && $this->app_key ) : ?>
<tr>
<th><?php _e('Configure ShareYourCart', 'woocommerce'); ?></th>
<td>
<p><?php _e('You can choose how much of a discount to give (in fixed amount, percentage, or free shipping) and to which social media channels it should it be applied. You can also define what the advertisement should say, so that it fully benefits your sales.', 'woocommerce'); ?></p>
<p><a href="http://www.shareyourcart.com/configure/?app_key=<?php echo $this->app_key; ?>&amp;client_id=<?php echo $this->client_id; ?>&amp;email=<?php echo $this->email; ?>" class="button" target="_blank"><?php _e('Configure', 'woocommerce'); ?></a></p>
</td>
</tr>
<?php endif; ?>
</table>
<script type="text/javascript">
jQuery('#woocommerce_shareyourcart_button_style').change(function(){
var value = jQuery(this).val();
if ( value == 'standard_button' ) {
jQuery('.standard_button').closest('tr').show();
jQuery('.image_button').closest('tr').hide();
jQuery('.custom_html').closest('tr').hide();
}
if ( value == 'image_button' ) {
jQuery('.standard_button').closest('tr').hide();
jQuery('.image_button').closest('tr').show();
jQuery('.custom_html').closest('tr').hide();
}
if ( value == 'custom_html' ) {
jQuery('.standard_button').closest('tr').hide();
jQuery('.image_button').closest('tr').hide();
jQuery('.custom_html').closest('tr').show();
}
}).change();
</script>
<!-- Section -->
<div><input type="hidden" name="section" value="<?php echo $this->id; ?>" /></div>
<?php
}
/**
* Initialise Settings Form Fields
*/
function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'label' => __( 'Enable ShareYourCart integration', 'woocommerce' ),
'type' => 'checkbox',
'default' => 'no',
),
'client_id' => array(
'title' => __( 'Client ID', 'woocommerce' ),
'description' => __( 'Get your client ID by creating a ShareYourCart account.', 'woocommerce' ),
'type' => 'text',
'default' => '',
'css' => 'width: 300px'
),
'app_key' => array(
'title' => __( 'App Key', 'woocommerce' ),
'description' => __( 'Get your app key by creating a ShareYourCart account.', 'woocommerce' ),
'type' => 'text',
'default' => '',
'css' => 'width: 300px'
),
'email' => array(
'title' => __( 'Email address', 'woocommerce' ),
'description' => __( 'The email address you used to sign up for ShareYourCart.', 'woocommerce' ),
'type' => 'text',
'default' => get_option('admin_email'),
'css' => 'width: 300px'
),
'show_on_product' => array(
'title' => __( 'Show button by default on:', 'woocommerce' ),
'label' => __( 'Product page', 'woocommerce' ),
'type' => 'checkbox',
'default' => 'yes',
),
'show_on_cart' => array(
'label' => __( 'Cart page', 'woocommerce' ),
'type' => 'checkbox',
'default' => 'yes',
),
'button_style' => array(
'title' => __( 'Button style', 'woocommerce' ),
'description' => __( 'Select a style for your share buttons', 'woocommerce' ),
'default' => 'standard_button',
'type' => 'select',
'options' => array(
'standard_button' => __( 'Standard Button', 'woocommerce' ),
'custom_html' => __( 'Custom HTML', 'woocommerce' )
)
),
'button_skin' => array(
'title' => __( 'Button skin', 'woocommerce' ),
'description' => __( 'Select a skin for your share buttons', 'woocommerce' ),
'default' => 'orange',
'type' => 'select',
'options' => array(
'orange' => __( 'Orange', 'woocommerce' ),
'blue' => __( 'Blue', 'woocommerce' ),
'light' => __( 'Light', 'woocommerce' ),
'dark' => __( 'Dark', 'woocommerce' )
),
'class' => 'standard_button'
),
'button_position' => array(
'title' => __( 'Button position', 'woocommerce' ),
'description' => __( 'Where should the button be positioned?', 'woocommerce' ),
'default' => 'normal',
'type' => 'select',
'options' => array(
'normal' => __( 'Normal', 'woocommerce' ),
'floating' => __( 'Floating', 'woocommerce' )
),
'class' => 'standard_button'
),
'button_html' => array(
'title' => __( 'HTML for the button', 'woocommerce' ),
'description' => __( 'Enter the HTML code for your custom button.', 'woocommerce' ),
'default' => '<button>Get a <div class="shareyourcart-discount"></div> discount</button>',
'type' => 'textarea',
'class' => 'custom_html'
)
);
} // End init_form_fields()
}
/**
* Add the integration to WooCommerce
**/
function add_shareyourcart_integration( $integrations ) {
if ( ! class_exists('ShareYourCartAPI') ) // Only allow this integration if we're not already using shareyourcart via another plugin
$integrations[] = 'WC_ShareYourCart';
return $integrations;
}
add_filter('woocommerce_integrations', 'add_shareyourcart_integration' );

View File

@ -0,0 +1,24 @@
.button_iframe iframe {
width: 58px;
height: 230px;
position: fixed;
top:360px;
right:0px;
}
.button_iframe-normal iframe {
float:right;
height: 58px;
width: 230px;
position:relative;
z-index:1000;
}
.button_iframe-normal.button_height {
height: 60px;
}
#shareyourcart_button {
margin: .5em 0 0;
overflow: hidden;
}

View File

@ -1,4 +1,5 @@
<?php
/**
* CLASS: Share Your Cart Base
* AUTHOR: Barandi Solutions
@ -16,7 +17,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//this array is used to hold function calls between different instances of this class
private static $_SINGLE_FUNCTIONS_CALLS = array();
private static $_SDK_VERSION = '1.7'; //the first one is the SDK main version, while the second one is it's revision
private static $_SDK_VERSION = '1.6'; //the first one is the SDK main version, while the second one is it's revision
protected static $_DB_VERSION = '1.1';
/**
@ -422,8 +423,6 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
$button_img_hover = $this->getConfigValue("btn-img-h");
$button_img_hover_width = $this->getConfigValue("btn-img-h-width");
$button_img_hover_height = $this->getConfigValue("btn-img-h-height");
$is_product_page = $this->isSingleProduct();
switch ($current_button_type)
{
@ -690,7 +689,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
}
//make sure there is a session variable setup
if ( ! session_id() ) session_start();
session_start();
//since switching the API status has a great impact on how the UI looks, refresh the page
//just to make sure the UI is using the latest value
@ -765,7 +764,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
if($_FILES["button-img"]["name"]!='') {
$target_path = $this->getUploadDir();
$target_path = dirname(__FILE__). "/img/";
$target_path = $target_path . 'button-img.png';
@ -783,7 +782,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
}
if($_FILES["button-img-hover"]["name"]!='') {
$target_path = $this->getUploadDir();
$target_path = dirname(__FILE__). "/img/";
$target_path = $target_path . 'btn-img-hover.png';
@ -819,10 +818,6 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
include(dirname(__FILE__) . '/views/button-settings-page.php');
return ob_get_clean();
}
public function getUploadDir(){
return dirname(_FILE_). "/img/";
}
/**
* showDocumentation
@ -959,7 +954,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
//we can't relly on the fact that the table has been properly created, so check it!
if(!$this->existsTable($tableName))
throw new Exception(SyC::t('sdk','Cannot create table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName,'{sql}' => nl2br($sql))));
throw new Exception(SyC::t('sdk','Cannot create table "{table_name}". Check your database permissions.', array('{table_name}' => $tableName)));
}
/**
@ -982,12 +977,11 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
*/
protected function dropTable($tableName) {
$sql = "DROP TABLE $tableName";
$this->executeNonQuery($sql);
$this->executeNonQuery("DROP TABLE $tableName");
//we can't relly on the fact that the table has been properly droped, so check it!
if($this->existsTable($tableName))
throw new Exception(SyC::t('sdk','Cannot drop table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName, '{sql}' => nl2br($sql))));
if(!$this->existsTable($tableName))
throw new Exception(SyC::t('sdk','Cannot drop table "{table_name}". Check your database permissions.', array('{table_name}' => $tableName)));
}
/**

View File

@ -8,7 +8,7 @@
.button_iframe-normal iframe {
float:right;
height: 78px;
height: 58px;
width: 230px;
position:relative;
z-index:1000;

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 43 B

After

Width:  |  Height:  |  Size: 43 B

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 781 B

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<script type="text/javascript">
if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view']);
</script>

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<script type="text/javascript">
if(_gaq) _gaq.push(['_trackPageview', '/admin/recover-view']);
</script>

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/admin-style.css'); ?>" />
<script type="text/javascript">

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<script type="text/javascript">
if(_gaq) _gaq.push(['_trackPageview', '/admin-view']);
</script>

View File

@ -1,13 +1,11 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom">
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom">
<?php echo $button_html;?>
</a>
<!--
<script type="text/javascript">
(function() {
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
})();
</script> -->
</script>

View File

@ -1,6 +1,4 @@
<?php
if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
// If only the hover is uploaded
if((!$button_img or !$button_img_width or !$button_img_height) and ($button_img_hover and $button_img_hover_width and $button_img_hover_height)) {
$button_img = $button_img_hover;
@ -18,7 +16,7 @@
}
?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo $callbackDataAttr; ?> data-syc-layout="custom">
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button" <?php echo $callbackDataAttr; ?> data-syc-layout="custom">
ShareYourCart Discount
</a>
@ -50,11 +48,11 @@
}
?>
</style>
<!--
<script type="text/javascript">
(function() {
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
})();
</script> -->
</script>

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<?php if(!$this->isActive()) return; //if the plugin is not active, do not show this page ?>
<script type="text/javascript">
if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view']);

View File

@ -0,0 +1,11 @@
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" >
ShareYourCart Discount
</a>
<script type="text/javascript">
(function() {
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
})();
</script>

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<?php if(!$this->isActive()) return; //if the plugin is not active, do not show this page ?>
<script type="text/javascript">
if(_gaq) _gaq.push(['_trackPageview', '/admin/documentation']);

View File

@ -1,12 +1,9 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/style.css'); ?>" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/ie.css'); ?>" type="text/css"/>
<![endif]-->
<meta property="syc:client_id" content="<?php echo $this->getClientId(); ?>" />
<meta property="syc:callback_url" content="<?php echo $this->getButtonCallbackURL(); ?>" />
<?php if($this->isActive() & is_array($data)): ?>
<meta property="og:title" content="<?php echo htmlspecialchars(@$data['item_name']); ?>" />
@ -15,13 +12,4 @@
<meta property="og:image" content="<?php echo @$data['item_picture_url'] ?>" />
<meta property="syc:price" content="<?php echo @$data['item_price'] ?>" />
<?php endif; ?>
<script type="text/javascript">
(function() {
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
})();
</script>
<?php endif; ?>

View File

@ -1,4 +1,3 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<?php if($this->hasNewerVersion()): //if there is a newer version, show the upgrade message?>
<div class="syc-update-nag">
<strong><?php echo SyC::t('sdk','{link}ShareYourCart {version}</a> is available! {link}Please update now</a>.', array('{version}' => $this->getConfigValue('latest_version'), '{link}' => '<a href="'.$this->getConfigValue("download_url").'" target="_blank">')); ?></strong>

View File

@ -1,258 +0,0 @@
<?php
require_once "class.shareyourcart-wp.php";
class ShareYourCartWooCommerce extends ShareYourCartWordpressPlugin{
public $_plugin_name = "shareyourcart_woo_commerce";
public $_post_user_id = 1;
public function processInit() {
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case $this->_plugin_name:
$this->buttonCallback();
break;
case $this->_plugin_name.'_coupon':
$this->couponCallback();
break;
}
}
}
public function isCartActive() {
return true;
}
/*
*
* Extend the base class implementation
*
*/
public function pluginsLoadedHook() {
parent::pluginsLoadedHook();
if (!$this->isCartActive()) return;
add_action('init', array(&$this, 'processInit'));
$this->_hookButton();
}
private function _hookButton() {
if ($this->isCartActive()) {
if (isset($_GET['product']))
add_filter('woocommerce_product_description_heading', array(&$this, '_getProductButton'));
add_action('woocommerce_cart_contents', array(&$this, '_getCartButton'));
}
}
public function _getProductButton() {
$passed_arguments = func_get_args();
$description = array_shift($passed_arguments);
$ret = $description;
$ret .= $this->getProductButton();
return $ret;
}
public function _getCartButton() {
$ret = "";
$ret .= '<div id="shareyourcart_button" style="margin-top:20px;">';
$ret .= $this->getCartButton();
$ret .= '</div>';
$ret .= '<script>';
$ret .= 'jQuery(document).ready(function(){';
$ret .= 'jQuery("#shareyourcart_button").appendTo(".coupon:first");';
$ret .= '});';
$ret .= '</script>';
echo $ret;
}
public function getSecretKey() {
return '2cfd496d-7812-44ba-91ce-e43c59f6c680';
}
public function isSingleProduct() {
return isset($_GET['product']) ? true : false;
}
public function saveCoupon($token, $coupon_code, $coupon_value, $coupon_type) {
$post_id = $this->_saveCouponPost($coupon_code);
$this->_saveCouponMetaData($post_id, $this->_getCouponMetaData($coupon_type, $coupon_value));
parent::saveCoupon($token, $coupon_code, $coupon_value, $coupon_type);
}
public function applyCoupon($coupon_code) {
//$this->_loadWooCommerce();
//global $woocommerce;
//$woocommerce->cart->add_discount($coupon_code);
return;
}
private function _saveCouponPost($coupon_code) {
$new_post = array(
'post_title' => $coupon_code,
'post_name' => ereg_replace("[^A-Za-z0-9]", "", $coupon_code),
'post_content' => '',
'post_status' => 'publish',
'comment_status'=> 'closed',
'ping_status' => 'closed',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $this->_post_user_id,
'post_type' => 'shop_coupon',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
$new_post['ID'] = $post_id;
$new_post['guid']= get_bloginfo('url').'/?post_type=shop_coupon&p='.$post_id;
wp_update_post($new_post);
return $post_id;
}
private function _saveCouponMetaData($post_id, $metas) {
foreach ($metas as $meta_key=>$meta_value) {
$this->_saveSingleCouponMetaData($post_id, $meta_key, $meta_value);
}
}
private function _saveSingleCouponMetaData($post_id, $meta_key, $meta_value) {
$this->insertRow($this->getTableName('postmeta'),
array('post_id' => $post_id,
'meta_key' => $meta_key,
'meta_value' => $meta_value,
));
}
private function _getCouponMetaData($coupon_type, $discount_value) {
switch ($coupon_type) {
case 'amount':
$discount_type = 'fixed_product';
$free_shipping = 'no';
break;
case 'percent':
$discount_type = 'percent_product';
$free_shipping = 'no';
break;
case 'free_shipping':
$discount_type = 'fixed_product';
$discount_value = 0;
$free_shipping = 'yes';
break;
default :
$discount_type = 'fixed_cart';
$free_shipping = 'no';
}
return array(
'customer_email' => 'a:0:{}',
'minimum_amount' => '',
'exclude_product_categories' => 'a:0:{}',
'product_categories' => 'a:0:{}',
'free_shipping' => $free_shipping,
'apply_before_tax' => 'yes',
'expiry_date' => '',
'usage_limit' => 1,
'exclude_product_ids' => '',
'product_ids' => '',
'individual_use' => 'yes',
'coupon_amount' => $discount_value,
'discount_type' => $discount_type,
'_edit_lock' => '1333727222:1',
);
}
public function getButtonCallbackURL() {
global $wp_query;
$callback_url = get_bloginfo('wpurl').'/?action='.$this->_plugin_name;
if ($this->isSingleProduct()) {
$callback_url .= '&p='. $wp_query->post->ID;
}
return $callback_url;
}
public function buttonCallback() {
if (!$this->isCartActive()) return;
$this->_loadWooCommerce();
//specify the parameters
$params = array(
'callback_url' => get_bloginfo('wpurl').'/?action='.$this->_plugin_name.'_coupon'.(isset($_REQUEST['p']) ? '&p='.$_REQUEST['p'] : '' ),
'success_url' => get_option('shopping_cart_url'),
'cancel_url' => get_option('shopping_cart_url'),
);
//there is no product set, thus send the products from the shopping cart
if (!isset($_REQUEST['p'])) {
if (empty($_SESSION['cart']))
exit("Cart is empty");
foreach ($_SESSION['cart'] as $cart_details) {
$params['cart'][] = $this->_getProductDetails($cart_details['product_id']);
}
}
else {
$params['cart'][] = $this->_getProductDetails($_GET['p']);
}
try
{
$this->startSession($params);
}
catch(Exception $e) {
//display the error to the user
echo $e->getMessage();
}
exit;
}
private function _getProductDetails($product_id) {
$product = new WC_Product($product_id);
ob_start();
$product->get_image();
$image = ob_get_clean();
return array(
"item_name" => $product->get_title(),
"item_description" => $product->post->post_content,
"item_url" => $product->post->guid,
"item_price" => $product->price,
"item_picture_url" => $image,
);
}
public function loadSessionData() {
return;
}
private function _loadWooCommerce() {
// Sometimes the WooCommerce Class is not loaded...
if (!class_exists('Woocommerce', false)) {
require_once ABSPATH . 'wp-content/plugins/woocommerce/woocommerce.php';
}
// Important Classes Not included
if (!function_exists('has_post_thumbnail')) {
require_once ABSPATH . 'wp-includes/post-thumbnail-template.php';
}
}
}
$shareYourCartWooCommerce = new ShareYourCartWooCommerce();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

View File

@ -1,13 +0,0 @@
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?> <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" >
ShareYourCart Discount
</a>
<!--
<script type="text/javascript">
(function() {
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
})();
</script> -->

View File

@ -28,8 +28,8 @@ Keep a birds-eye view of incoming sales and reviews, stock levels and general st
= FEATURES =
Seriously, WooCommerce has got more features than you can shake a stick at. But dont just take our word for it, try it for yourself.
= BUNDLED GATEWAYS AND SHIPPING =
WooCommerce has enough power to be used straight out of the box and comes with the following payment gateways and shipping methods:
= BUNDLED GATEWAYS, SHIPPING AND INTEGRATIONS =
WooCommerce has enough power to be used straight out of the box and comes with the following payment gateways, shipping methods and third party integrations:
* PayPal Standard
* BACS
@ -40,6 +40,10 @@ WooCommerce has enough power to be used straight out of the box and comes with t
* International delivery
* Local delivery
* Local Pickup
* Google Analytics
* Sharedaddy
* ShareThis
* ShareYourCart
= EXTENSIONS =
Need a specific payment gateway? Perhaps additional shipping methods? WooCommerce has a plethora of eCommerce extensions available to provide just that: [View our extensions](http://www.woothemes.com/extensions/woocommerce-extensions/ "eCommerce extensions for WooCommerce from WooThemes").
@ -144,6 +148,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 1.5.5 =
* Feature - New integration section which allows other class-based integrations to be added.
* Feature - ShareYourCart integration built in.
* Feature - is_sold_individually() function for disabling quantity inputs for products
* Feature - Collect shipping address even when not required option
* Feature - Stock display options - show no stock amount, low stock amount, or always show stock amount

View File

@ -104,7 +104,11 @@ global $woocommerce;
<?php if ( get_option( 'woocommerce_enable_coupons' ) == 'yes' ) { ?>
<div class="coupon">
<label for="coupon_code"><?php _e('Coupon', 'woocommerce'); ?>:</label> <input name="coupon_code" class="input-text" id="coupon_code" value="" /> <input type="submit" class="button" name="apply_coupon" value="<?php _e('Apply Coupon', 'woocommerce'); ?>" />
<?php do_action('woocommerce_cart_coupon'); ?>
</div>
<?php } ?>

View File

@ -1,25 +1,9 @@
<?php
/**
* Single Product Share
*
* Sharing plugins can hook into here or you can add your own code directly.
*/
?>
<?php if (get_option('woocommerce_sharethis')) : ?>
<div class="social">
<iframe src="https://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
<span class="st_twitter"></span><span class="st_email"></span><span class="st_sharethis"></span><span class="st_plusone_button"></span>
</div>
<?php $sharethis = (is_ssl()) ? 'https://ws.sharethis.com/button/buttons.js' : 'http://w.sharethis.com/button/buttons.js'; ?>
<script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="<?php echo $sharethis; ?>"></script>
<script type="text/javascript">stLight.options({publisher:"<?php echo get_option('woocommerce_sharethis'); ?>"});</script>
<?php endif; ?>
<?php if (get_option('woocommerce_sharedaddy') && function_exists('sharing_display')) : ?>
<div class="social"><?php echo sharing_display(); ?></div>
<?php endif; ?>
<?php do_action('woocommerce_share'); // Sharing plugins can hook into here ?>

View File

@ -37,9 +37,11 @@ wp_delete_post( get_option('woocommerce_pay_page_id'), true );
wp_delete_post( get_option('woocommerce_thanks_page_id'), true );
// Tables
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."woocommerce_attribute_taxonomies");
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."woocommerce_downloadable_product_permissions");
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."woocommerce_termmeta");
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_attribute_taxonomies" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_downloadable_product_permissions" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "woocommerce_termmeta" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->base_prefix . "shareyourcart_tokens" );
$wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->base_prefix . "shareyourcart_coupons" );
// Delete options
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce_%';");

View File

@ -1033,136 +1033,6 @@ function woocommerce_download_product() {
endif;
}
/**
* Google Analytics standard tracking
**/
function woocommerce_google_tracking() {
global $woocommerce;
if ( is_admin() || current_user_can('manage_options') || get_option('woocommerce_ga_standard_tracking_enabled') == "no" ) return;
$tracking_id = get_option('woocommerce_ga_id');
if ( ! $tracking_id ) return;
$loggedin = ( is_user_logged_in() ) ? 'yes' : 'no';
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
$current_user = get_user_by('id', $user_id);
$username = $current_user->user_login;
} else {
$user_id = '';
$username = __('Guest', 'woocommerce');
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', '<?php echo $tracking_id; ?>'],
['_setCustomVar', 1, 'logged-in', '<?php echo $loggedin; ?>', 1],
['_setCustomVar', 2, 'user-id', '<?php echo $user_id; ?>', 1],
['_setCustomVar', 3, 'username', '<?php echo $username; ?>', 1],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
/**
* Google Analytics eCommerce tracking
**/
function woocommerce_ecommerce_tracking( $order_id ) {
global $woocommerce;
if ( is_admin() || current_user_can('manage_options') || get_option('woocommerce_ga_ecommerce_tracking_enabled') == "no" ) return;
$tracking_id = get_option('woocommerce_ga_id');
if ( ! $tracking_id ) return;
// Doing eCommerce tracking so unhook standard tracking from the footer
remove_action('wp_footer', 'woocommerce_google_tracking');
// Get the order and output tracking code
$order = new WC_Order($order_id);
$loggedin = (is_user_logged_in()) ? 'yes' : 'no';
if (is_user_logged_in()) {
$user_id = get_current_user_id();
$current_user = get_user_by('id', $user_id);
$username = $current_user->user_login;
} else {
$user_id = '';
$username = __('Guest', 'woocommerce');
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', '<?php echo $tracking_id; ?>'],
['_setCustomVar', 1, 'logged-in', '<?php echo $loggedin; ?>', 1],
['_setCustomVar', 2, 'user-id', '<?php echo $user_id; ?>', 1],
['_setCustomVar', 3, 'username', '<?php echo $username; ?>', 1],
['_trackPageview']
);
_gaq.push(['_addTrans',
'<?php echo $order_id; ?>', // order ID - required
'<?php bloginfo('name'); ?>', // affiliation or store name
'<?php echo $order->order_total; ?>', // total - required
'<?php echo $order->get_total_tax(); ?>', // tax
'<?php echo $order->get_shipping(); ?>', // shipping
'<?php echo $order->billing_city; ?>', // city
'<?php echo $order->billing_state; ?>', // state or province
'<?php echo $order->billing_country; ?>' // country
]);
// Order items
<?php if ($order->get_items()) foreach($order->get_items() as $item) : $_product = $order->get_product_from_item( $item ); ?>
_gaq.push(['_addItem',
'<?php echo $order_id; ?>', // order ID - required
'<?php if (!empty($_product->sku))
echo __('SKU:', 'woocommerce') . ' ' . $_product->sku;
else
echo $_product->id;
?>', // SKU/code - required
'<?php echo $item['name']; ?>', // product name
'<?php if (isset($_product->variation_data)){
echo woocommerce_get_formatted_variation( $_product->variation_data, true );
} else {
$out = array();
$categories = get_the_terms($_product->id, 'product_cat');
foreach ( $categories as $category ){
$out[] = $category->name;
}
echo join( "/", $out);
}
?>', // category or variation
'<?php echo ($item['line_total']/$item['qty']); ?>', // unit price - required
'<?php echo $item['qty']; ?>' // quantity - required
]);
<?php endforeach; ?>
_gaq.push(['_trackTrans']); // submits transaction to the Analytics servers
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<?php
}
/**
* ecommerce tracking with piwik
*/

View File

@ -137,8 +137,6 @@ add_action( 'init', 'woocommerce_process_registration' );
add_action('init', 'woocommerce_download_product');
/* Analytics */
add_action( 'wp_footer', 'woocommerce_google_tracking' );
add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking' );
add_action( 'woocommerce_thankyou', 'woocommerce_ecommerce_tracking_piwik' );
/* RSS Feeds */

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 1.5.4
* Version: 1.5.5
* Author: WooThemes
* Author URI: http://woothemes.com
* Requires at least: 3.3
@ -17,8 +17,6 @@
* @author WooThemes
*/
//if ( get_option('woocommerce_shareyourcart') == 'yes' ) require_once("integration/shareyourcart/class.shareyourcart-wp-woo-commerce.php");
if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( !class_exists( 'Woocommerce' ) ) {
@ -34,7 +32,7 @@ class Woocommerce {
/** Version ***************************************************************/
var $version = '1.5.4';
var $version = '1.5.5';
/** URLS ******************************************************************/
@ -57,6 +55,7 @@ class Woocommerce {
var $countries;
var $woocommerce_email;
var $checkout;
var $integrations;
/** Taxonomies ************************************************************/
@ -113,11 +112,17 @@ class Woocommerce {
include( 'classes/class-wc-product.php' ); // Product class
include( 'classes/class-wc-product-variation.php' ); // Product variation class
include( 'classes/class-wc-tax.php' ); // Tax class
include( 'classes/class-wc-settings-api.php' ); // Settings API
// Include shipping modules and gateways
include( 'classes/class-wc-settings-api.php' );
// Include Core Payment Gateways
include( 'classes/gateways/class-wc-payment-gateways.php' );
include( 'classes/gateways/class-wc-payment-gateway.php' );
include( 'classes/gateways/class-wc-bacs.php' );
include( 'classes/gateways/class-wc-cheque.php' );
include( 'classes/gateways/class-wc-paypal.php' );
include( 'classes/gateways/class-wc-cod.php' );
// Include Core Shipping Methods
include( 'classes/shipping/class-wc-shipping.php' );
include( 'classes/shipping/class-wc-shipping-method.php' );
include( 'classes/shipping/class-wc-flat-rate.php' );
@ -125,10 +130,14 @@ class Woocommerce {
include( 'classes/shipping/class-wc-free-shipping.php' );
include( 'classes/shipping/class-wc-local-delivery.php' );
include( 'classes/shipping/class-wc-local-pickup.php' );
include( 'classes/gateways/class-wc-bacs.php' );
include( 'classes/gateways/class-wc-cheque.php' );
include( 'classes/gateways/class-wc-paypal.php' );
include( 'classes/gateways/class-wc-cod.php' );
// Include Core Integrations
include( 'classes/integrations/class-wc-integration.php' );
include( 'classes/integrations/class-wc-integrations.php' );
include( 'classes/integrations/google-analytics/class-wc-google-analytics.php' );
include( 'classes/integrations/sharethis/class-wc-sharethis.php' );
include( 'classes/integrations/sharedaddy/class-wc-sharedaddy.php' );
include( 'classes/integrations/shareyourcart/class-wc-shareyourcart.php' );
}
/**
@ -189,10 +198,12 @@ class Woocommerce {
$this->payment_gateways = new WC_Payment_gateways(); // Payment gateways. Loads and stores payment methods
$this->shipping = new WC_Shipping(); // Shipping class. loads and stores shipping methods
$this->countries = new WC_Countries(); // Countries class
$this->integrations = new WC_Integrations(); // Integrations class
// Init shipping and payment gateways
// Init shipping, payment gateways, and integrations
$this->shipping->init();
$this->payment_gateways->init();
$this->integrations->init();
// Classes/actions loaded for the frontend and for ajax requests
if ( ! is_admin() || defined('DOING_AJAX') ) {