Support » Plugin: GamiPress » User Earnings not showing point type

  • Resolved isabelpinhel

    (@isabelpinhel)


    Hi there,

    I wrote the code below based on your documentation. It assigns points, so it is working but the issue is that the transaction does not show on user’s earnings. How can I make it show?

    add_action( 'woocommerce_payment_complete', 'zeller_award_points_per_amount_sold_on_woocommerce' );
    
    function zeller_award_points_per_amount_sold_on_woocommerce( $order_id ) {
    
        $order = wc_get_order( $order_id );
    
        // The ratio value used to convert the amount spent into points
        // Setting it to 1 will award the same points as amount spent ($40 = 40 points)
        // Setting it to 2 will award the double of points of amount spent ($40 = 80 points)
        // Setting it to 0.5 will award the half of points of amount spent ($40 = 20 points)
        $ratio = 1;
    
        // The points type slug you want to convert the amount
        $points_type = 'zeller';
    
    	//Get vendor ID for product in order
        foreach( $order->get_items() as $item_id => $line_item ){
            $vendor_id = get_post_field( 'post_author', $line_item->get_product_id());
        }
    
        // Award the points to the vendor
        gamipress_award_points_to_user( $vendor_id, absint( $order->get_total() * $ratio ), $points_type );
    
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author rubengc

    (@rubengc)

    Hi @isabelpinhel

    If you check this code, it just updates the user points balance without inset the user earning entry

    Actually GamiPress user earnings are designed to register all earnings related to GamiPress elements (achievements, points awards, steps, ranks, etc)

    But they are not designed to support custom entries that are not associated to any element so you will require a great amount of code to insert a custom user earning and display it correctly

    Just one thing, do you that this code snippet is not required anymore?
    We have been released a free plugin to handle this functionality and you can check it here:
    https://wordpress.org/plugins/gamipress-wc-points-per-purchase-total/

    Best regards

    isabelpinhel

    (@isabelpinhel)

    Hi,

    Thanks so much for your reply.
    Re. new plugin: I am currently using the code snippet to assign points to the vendor (product author) not the user (customer) that buys the product. And form what I could tell the plugin will assign points to customer. But thanks so much for letting me know about it, I did not know about it.

    Isabel

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.