Changeset 949997
- Timestamp:
- 07/17/2014 12:25:53 AM (12 years ago)
- Location:
- segmentio/trunk
- Files:
-
- 3 added
- 1 deleted
- 4 edited
-
Makefile (modified) (1 diff)
-
README.md (deleted)
-
Readme.md (added)
-
analytics-wordpress.php (modified) (2 diffs)
-
bin (added)
-
bin/deploy (added)
-
integrations/ecommerce/woocommerce.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
segmentio/trunk/Makefile
r709542 r949997 1 1 2 # Open the WordPress site and admin. 2 # 3 # Commands 4 # 5 6 deploy: 7 @bin/deploy 8 3 9 test: 4 open http://localhost:8888/analytics-wordpress/test/wp-admin/options-general.php?page=analytics-wordpress 5 open http://localhost:8888/analytics-wordpress/test/ 10 # TODO 6 11 7 # Turns the testing plugin into a real folder, for more accurate testing. 8 test-folder: 9 rm -rf test/wp-content/plugins/analytics-wordpress 10 cp -r ./ ../analytics-wordpress-temp 11 rm -rf ../analytics-wordpress-temp/test 12 rm -rf ../analytics-wordpress-temp/.git 13 mv ../analytics-wordpress-temp test/wp-content/plugins/analytics-wordpress 12 # 13 # Phonies 14 # 14 15 15 # Turns the testing plugin into a symlink, for faster testing. 16 test-symlink: 17 rm -rf test/wp-content/plugins/analytics-wordpress 18 ln -s ../../.. test/wp-content/plugins/analytics-wordpress 19 16 .PHONY: deploy 20 17 .PHONY: test -
segmentio/trunk/analytics-wordpress.php
r948394 r949997 4 4 Plugin URI: https://segment.io/plugins/wordpress 5 5 Description: The hassle-free way to integrate any analytics service into your WordPress site. 6 Version: 1.0. 06 Version: 1.0.1 7 7 License: GPLv2 8 8 Author: Segment.io … … 179 179 * Current plugin version. 180 180 */ 181 const VERSION = '1.0. 0';181 const VERSION = '1.0.1'; 182 182 183 183 /** -
segmentio/trunk/integrations/ecommerce/woocommerce.php
r948394 r949997 105 105 public function add_to_cart( $key, $id, $quantity ) { 106 106 107 if ( ! is_object( WC()->cart ) ) { 108 return; 109 } 110 107 111 $items = WC()->cart->get_cart(); 108 112 $cart_item = $items[ $key ]; … … 118 122 ) 119 123 ); 124 120 125 } 121 126 … … 136 141 $track = $args[0]; 137 142 138 if ( false !== ( $product = Segment_Cookie::get_cookie( 'added_to_cart' ) ) ) { 143 if ( false !== ( $cookie = Segment_Cookie::get_cookie( 'added_to_cart' ) ) ) { 144 145 if ( ! is_object( WC()->cart ) ) { 146 return $track; 147 } 139 148 140 149 $items = WC()->cart->get_cart(); 141 $product = json_decode( $product ); 142 $_product = $items[ $product->key ]; 143 144 $item = array( 145 'id' => $product->ID, 146 'sku' => $_product['data']->get_sku(), 147 'name' => $product->name, 148 'price' => $product->price, 149 'quantity' => $product->quantity, 150 'category' => implode( ', ', wp_list_pluck( wc_get_product_terms( $product->ID, 'product_cat' ), 'name' ) ), 151 ); 152 153 $track = array( 154 'event' => __( 'Added Product', 'segment' ), 155 'properties' => $item, 156 'http_event' => 'added_to_cart' 157 ); 150 $_product = json_decode( $cookie ); 151 152 if ( is_object( $_product ) ) { 153 $product = get_product( $_product->ID ); 154 155 if ( $product ) { 156 $item = array( 157 'id' => $product->id, 158 'sku' => $product->get_sku(), 159 'name' => $product->get_title(), 160 'price' => $product->get_price(), 161 'quantity' => $_product->quantity, 162 'category' => implode( ', ', wp_list_pluck( wc_get_product_terms( $product->id, 'product_cat' ), 'name' ) ), 163 ); 164 165 $track = array( 166 'event' => __( 'Added Product', 'segment' ), 167 'properties' => $item, 168 'http_event' => 'added_to_cart' 169 ); 170 } 171 } 158 172 159 173 } … … 174 188 */ 175 189 public function remove_from_cart( $key ) { 190 191 if ( ! is_object( WC()->cart ) ) { 192 return; 193 } 194 176 195 $items = WC()->cart->get_cart(); 177 196 $cart_item = $items[ $key ]; … … 205 224 $track = $args[0]; 206 225 207 if ( false !== ( $product = Segment_Cookie::get_cookie( 'removed_from_cart' ) ) ) { 208 $items = WC()->cart->get_cart(); 209 $product = json_decode( $product ); 210 $_product = $items[ $product->key ]; 211 212 $item = array( 213 'id' => $product->ID, 214 'sku' => $_product['data']->get_sku(), 215 'name' => $product->name, 216 'price' => $product->price, 217 'quantity' => 0, 218 'category' => implode( ', ', wp_list_pluck( wc_get_product_terms( $product->ID, 'product_cat' ), 'name' ) ), 219 ); 220 221 $track = array( 222 'event' => __( 'Removed Product', 'segment' ), 223 'properties' => $item, 224 'http_event' => 'removed_from_cart' 225 ); 226 226 if ( false !== ( $cookie = Segment_Cookie::get_cookie( 'removed_from_cart' ) ) ) { 227 228 if ( ! is_object( WC()->cart ) ) { 229 return $track; 230 } 231 232 $items = WC()->cart->get_cart(); 233 234 $_product = json_decode( $cookie ); 235 236 if ( is_object( $_product ) ) { 237 $product = get_product( $_product->ID ); 238 239 if ( $product ) { 240 $item = array( 241 'id' => $product->ID, 242 'sku' => $product->get_sku(), 243 'name' => $product->get_title(), 244 'price' => $product->get_price(), 245 'quantity' => 0, 246 'category' => implode( ', ', wp_list_pluck( wc_get_product_terms( $product->ID, 'product_cat' ), 'name' ) ), 247 ); 248 249 $track = array( 250 'event' => __( 'Removed Product', 'segment' ), 251 'properties' => $item, 252 'http_event' => 'removed_from_cart' 253 ); 254 } 255 } 227 256 } 228 257 -
segmentio/trunk/readme.txt
r948394 r949997 4 4 Requires at least: 3.6 5 5 Tested up to: 3.9.2 6 Stable tag: 0.66 Stable tag: 1.0.1 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 61 61 62 62 == Screenshots == 63 s 63 64 64 65 65 == Changelog == 66 67 = 1.0.1 = 68 * Fixes fatal error when tracking WooCommerce products. 66 69 67 70 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.