Created
December 11, 2014 11:32
-
-
Save warrendholmes/dc695d4fcbaba04128b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$order_data_normalized = array(); | |
$starter_bundle = array('27147','18618','18718','18686'); | |
$row = 1; | |
if (($handle = fopen("/Users/warrenholmes/Sites/phpinfo/wp_woocommerce_downloadable_product_permissions.csv", "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$row++; | |
if( isset( $order_data_normalized[$data[2]] )){ | |
$order_data_normalized[$data[2]][] = $data[1]; | |
}else{ | |
$order_data_normalized[$data[2]][] = $data[1]; | |
} | |
} | |
fclose($handle); | |
} | |
$bought_starter_bundle = 0; | |
$bought_happy_bundle = 0; | |
$bought_sensei_bundle = 0; | |
foreach ($order_data_normalized as $key => $order_data) { | |
//Work out the started bundle purchases | |
if( in_array( '27147', $order_data) && in_array( '18618', $order_data) && in_array( '18718', $order_data) && in_array( '18686', $order_data)){ | |
$bought_starter_bundle++; | |
} | |
//Work out happy shop bundle | |
if( in_array( '527886', $order_data) && in_array( '512186', $order_data) && in_array( '473617', $order_data) && in_array( '466854', $order_data) && in_array( '521947', $order_data) && in_array( '512162', $order_data) && in_array( '455753', $order_data) && in_array( '506329', $order_data) && in_array( '210259', $order_data)){ | |
$bought_happy_bundle++; | |
} | |
if( in_array( '152116', $order_data) && in_array( '18775', $order_data) && in_array( '543363', $order_data) && in_array( '247517', $order_data)){ | |
$bought_sensei_bundle++; | |
} | |
} | |
echo $bought_happy_bundle . ' ' . $bought_starter_bundle . ' ' . $bought_sensei_bundle; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment