Created
January 30, 2014 08:23
-
-
Save kloon/8704570 to your computer and use it in GitHub Desktop.
WooCommerce import Points & Rewards using Customer Order CSV Importer
This file contains 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 | |
add_action( 'woocommerce_api_points_rewards_custom_generator', 'wc_points_rewards_generate_custom_points' ); | |
function wc_points_rewards_generate_custom_points() { | |
$customers = get_users( array( | |
'meta_key' => 'wc_points_balance' | |
) ); | |
foreach ( $customers as $customer ) { | |
$points = get_user_meta( $customer->ID, 'wc_points_balance', true ); | |
if ( $points > 0 ) { | |
if ( WC_Points_Rewards_Manager::increase_points( $customer->ID, $points, 'IMPORT' ) ) { | |
print $customer->user_nicename . ', ' . $points . ' imported<br>'; | |
delete_user_meta( $customer->ID, 'wc_points_balance' ); | |
wp_cache_delete( $customer->ID, 'user' . '_meta' ); | |
} else print 'Import Failed: ' . $customer->user_nicename; | |
} | |
} | |
die(); | |
} |
Does not work. I used 'wc_points_balance' as the field name, nothing happens.
The meta key is just points_balance
@C00woot
Hi has anyone got this to work? I have the code loaded in functions.php and when I run the importer using a simple test with a single email address and points column (labelled wc_points_balance) it asks to map the column headers to the customer database. of course the points fields are not there, so I wonder how this is achieved?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does not work. I used 'wc_points_balance' as the field name, nothing happens.