Changeset 808756
- Timestamp:
- 11/22/2013 10:21:46 AM (12 years ago)
- Location:
- woocommerce-piwik-integration
- Files:
-
- 9 added
- 2 edited
-
tags/1.0 (added)
-
tags/1.0/classes (added)
-
tags/1.0/classes/class-wc-piwik-integration.php (added)
-
tags/1.0/classes/class-wc-piwik-tracker.php (added)
-
tags/1.0/readme.txt (added)
-
tags/1.0/wc-piwik-integration.php (added)
-
trunk/classes (added)
-
trunk/classes/class-wc-piwik-integration.php (added)
-
trunk/classes/class-wc-piwik-tracker.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/wc-piwik-integration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-piwik-integration/trunk/readme.txt
r714309 r808756 5 5 Requires at least: 3.5 6 6 Tested up to: 3.5 7 Stable tag: 0.1.17 Stable tag: 1.0 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 15 15 This plugin integrates your WooCommerce store with the [WP-Piwik plugin](http://wordpress.org/extend/plugins/wp-piwik/) plugin, providing support for tracking your checkout process through Piwik. Please note that you need your own Piwik installation for this plugin (and WP-Piwik) to function, look at the [Piwik website](http://piwik.org/) to get more information. 16 16 17 Starting WooCommerce 2.1, this integration will no longer be part of WooCommerce and will only be available by using this plugin. 17 Starting WooCommerce 2.1, this integration will no longer be part of WooCommerce and will only be available by using this plugin. More information about this in the [FAQ](http://wordpress.org/extend/plugins/woocommerce-piwik-integration/faq/). 18 18 19 19 Contributions are welcome via the [GitHub repository](https://github.com/coenjacobs/wc-piwik-integration). … … 31 31 = Where can I find the setting for this plugin? = 32 32 33 This plugin has no settings. It just integrates WooCommerce with your own Piwik install and the WP-Piwik plugin. 33 This plugin has no settings. It just integrates WooCommerce with your own [Piwik](http://piwik.org/) install and the [WP-Piwik plugin](http://wordpress.org/extend/plugins/wp-piwik/). 34 35 = Why does this plugin say it is doing nothing? = 36 37 Starting the WooCommerce 2.1 release, the Piwik integration for WooCommerce is no longer part of the WooCommerce plugin. 38 39 Until you've updated to WooCommerce 2.1, this plugin puts itself in some sort of hibernate mode. 40 41 You can leave this plugin activated and it will seamlessly take over the integration that once was in the WooCommerce plugin, once you update to the next version. 34 42 35 43 == Changelog == 44 45 = 1.0 - 22/11/2013 = 46 * Feature: Plugin checks for required WooCommerce version or doesn't do anything 47 * Tweak: Split up logic and output into classes, powered by a lean bootstrap script 36 48 37 49 = 0.1.1 - 17/05/2013 = -
woocommerce-piwik-integration/trunk/wc-piwik-integration.php
r714309 r808756 6 6 Author: Coen Jacobs 7 7 Author URI: http://coenjacobs.me 8 Version: 0.1.18 Version: 1.0 9 9 */ 10 10 11 if ( ! function_exists( 'woocommerce_ecommerce_tracking_piwik' ) ) { 12 add_action( 'woocommerce_thankyou', 'wcpiwik_ecommerce_tracking_piwik' ); 11 define( 'WC_PIWIK_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) ); 13 12 14 function wcpiwik_ecommerce_tracking_piwik( $order_id ) { 15 global $woocommerce; 13 include( 'classes/class-wc-piwik-integration.php' ); 16 14 17 // Don't track admin 18 if ( current_user_can('manage_options') ) 19 return; 20 21 // Call the Piwik ecommerce function if WP-Piwik is configured to add tracking codes to the page 22 $wp_piwik_global_settings = get_option( 'wp-piwik_global-settings' ); 23 24 // Return if Piwik settings are not here, or if global is not set 25 if ( ! isset( $wp_piwik_global_settings['add_tracking_code'] ) || ! $wp_piwik_global_settings['add_tracking_code'] ) 26 return; 27 if ( ! isset( $GLOBALS['wp_piwik'] ) ) 28 return; 29 30 // Get the order and get tracking code 31 $order = new WC_Order( $order_id ); 32 ob_start(); 33 ?> 34 try { 35 // Add order items 36 <?php if ( $order->get_items() ) foreach( $order->get_items() as $item ) : $_product = $order->get_product_from_item( $item ); ?> 37 38 piwikTracker.addEcommerceItem( 39 "<?php echo esc_js( $_product->get_sku() ); ?>", // (required) SKU: Product unique identifier 40 "<?php echo esc_js( $item['name'] ); ?>", // (optional) Product name 41 "<?php 42 if ( isset( $_product->variation_data ) ) 43 echo esc_js( woocommerce_get_formatted_variation( $_product->variation_data, true ) ); 44 ?>", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"] 45 <?php echo esc_js( $order->get_item_total( $item ) ); ?>, // (recommended) Product price 46 <?php echo esc_js( $item['qty'] ); ?> // (optional, default to 1) Product quantity 47 ); 48 49 <?php endforeach; ?> 50 51 // Track order 52 piwikTracker.trackEcommerceOrder( 53 "<?php echo esc_js( $order->get_order_number() ); ?>", // (required) Unique Order ID 54 <?php echo esc_js( $order->get_total() ); ?>, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount) 55 false, // (optional) Order sub total (excludes shipping) 56 <?php echo esc_js( $order->get_total_tax() ); ?>, // (optional) Tax amount 57 <?php echo esc_js( $order->get_shipping() ); ?>, // (optional) Shipping amount 58 false // (optional) Discount offered (set to false for unspecified parameter) 59 ); 60 } catch( err ) {} 61 <?php 62 $code = ob_get_clean(); 63 $woocommerce->add_inline_js( $code ); 64 } 65 } 15 global $wc_piwik_integration; 16 $wc_piwik_integration = new WC_Piwik_Integration();
Note: See TracChangeset
for help on using the changeset viewer.