Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Point Payout
- * Pay 2% of the order total as points to buyer.
- * Will only pay if:
- * - Buyer is logged in
- * - Buyer pays using a non-manual payment gateway
- * - Buyer is not excluded from using myCRED
- * - myCRED is enabled
- *
- * @version 1.0
- */
- add_action( 'woocommerce_payment_complete', 'mycred_pro_woo_purchase_reward' );
- function mycred_pro_woo_purchase_reward( $order_id )
- {
- if ( ! function_exists( 'mycred' ) ) return;
- $order = new WC_Order( $order_id );
- if ( $order->order_total == 0.00 || $order->order_total == 0 ) return;
- $point_type = 'mycred_default';
- $mycred = mycred( $point_type );
- // Make sure buyer only get points once per order
- if ( $mycred->has_entry( 'shopping_reward', $order_id, $order->user_id ) ) return;
- // Add reward
- $mycred->add_creds(
- 'shopping_reward',
- $order->user_id,
- ( $order->order_total * 0.02 ),
- 'Reward for store purchase',
- $order_id,
- array( 'ref_type' => 'post' ),
- $point_type
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement