Buying myCRED points using WooCommerce instead of going through shortcodes

front page Forums How-to Questions Buying myCRED points using WooCommerce instead of going through shortcodes

This topic contains 21 replies, has 6 voices, and was last updated by Avatar Elnin 3 years ago.

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #14546
    Avatar
    Huy N

    Hi,

    I would like to make a WooCommerce Product (for example, Gold Package) that if a user Buys them (using real money, just like buying a regular WooCommerce product), a certain points will be added to that user accounts. It’s like a virtual currency system.

    Is that possible with myCRED?

    P/S: Please do not recommend buyCRED. I am trying to avoid shortcode. I’d like people to see it as a product.

    Thank you.

    #14574
    Avatar
    WPExperts

    Hi.

    I promise, I will not mention buyCRED šŸ™‚

    Go create a new product in WooCommerce and make it virtual. In the top right corner you should see “myCRED Reward” which allows you to set a point amount the user gets when they pay for this product. Set the amount you want them to get and save.

    A user then needs to be logged in and buy this product using real money to get the points. Once the payment has been marked as paid by the gateway you use, the points are paid out.

    A few things to keep in mind:

    1. Points will not be awarded if the user is not logged in and does not create an account with their order.

    2. By default, myCRED will not pay out points if the order was paid with points (can be overriden).

    3. If the user is set to be excluded from using myCRED, they will also not receive points.

    4. If you use a manual payment gateway like check or bank transfer then points will not be awarded out. (can be overriden).

    #15192
    Avatar
    Andre

    Hi,
    I also set it up like this.
    But we have a problem, cause the erotic stuff we sell are streaming cam shows, so many payment provders are out.
    We need to have a package with coijns to be paid over bank transfer and invoice, but we would need to have to know how it can be overriden, that the coins can be rewarded…
    Can you help please?

    Andre

    #15193
    Avatar
    Andre

    I ttried now witht he setting of the product
    virtual ticked
    and
    downloadable product ticked which sets the product order status to completed on clients account overview, so that client can download product.
    But not in admins view, thats probably why it doesnt help.
    But the coins isnt balanced over to the coins.
    How can this be achieved.

    Cause this then work with a plugin like WooCommerce Order Status Control cause it sets the status to completed per choice.

    I need the coins to be credited to the coins aaccount after buy…
    Please help

    #15194
    Avatar
    WPExperts

    You could adjust the point payout to be done when an order has been marked as Completed instead of Paid.

    You could use this code snippet for example to do just that. Simply paste the code into your theme’s functions.php file.

    https://gist.github.com/gabrielmerovingi/f435a50a76e9608b38fb

    Alternatively you could always go and manually pay out a point purchase on the Users page in your admin area.

    #15195
    Avatar
    Andre

    Hi,
    yes, great will look. I just tried everything with status. and this doesnt work…
    https://wordpress.org/plugins/woocommerce-autocomplete-order/

    or functions code:

    /**
    * Auto Complete all WooCommerce orders.
    * Add to theme functions.php file
    */
     
    add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
    function custom_woocommerce_auto_complete_order( $order_id ) {
        global $woocommerce;
     
        if ( !$order_id )
            return;
        $order = new WC_Order( $order_id );
        $order->update_status( 'completed' );
    }

    But maybe this functions code will work when I would know what a virtual product is called instead of new WC_Order( $order_id )
    u no?
    lemme try your advice

    your code snippet would be great if it works for virtual producs only…
    is this much of stuff coding needed?

    #15198
    Avatar
    WPExperts

    In WooCommerce, purchasing a “Virtual Product” will cause the status to change to “Processing” when an order has been paid. If the product is “Downloadable” then the order should be set to “Completed” when paid.

    Now when it comes to manual payment gateways like “Check” or “Bank Transfer” this will not work since these gateways will never mark anything as “Paid” which in turn I suspect does not trigger the plugin you are using.

    I would not use the code you pasted in as it would mark all orders as completed once a user completes the checkout process.

    An alternative would be to add a “Payout” button / link on the orders page in WooCommerce. So if an order is marked to be paid via a manual gateway, the link shows up for admins and clicking it would then trigger the payout process in myCRED for that particular order. But this option would have some requirements:

    – All products must be set to be virtual and not downloadable (unless users also need to download something with each point purchase).
    – No third-party plugins can be used that attempts to do similar tasks.

    #15199
    Avatar
    Andre

    Deactivated the plugin first: https://wordpress.org/plugins/woocommerce-autocomplete-order/
    then ok, I added the code to the functions.php of the child theme.
    And I ordered with bank transfer and it doesnt change a status.
    no coins rewarded too.

    Yes, I could add the coins manually withou even to change anything in woo.
    But as we are selling streaming shows, the client would like to enter immideately…

    #15200
    Avatar
    Andre

    This is also a problem of the logical shopping cart flow… mmh. wondering

    #15201
    Avatar
    WPExperts

    The code snippet I give you does NOT change status. It changes myCRED, to instead of waiting for an order to be marked by Woo as “paid” it should wait for the order to get the status “Completed”.

    So make an order, select to pay using bank transfer for example, place the order so it shows up as pending payment, then go and edit the order and mark it as completed. The points should then be paid out (assuming you pasted the code I gave you into your theme’s functions.php file).

    #15202
    Avatar
    Andre

    ok, thx for the code.
    I just mean, when I need to go anywhere to press anything, then it is not automated on bank/ cheque … then I could also load the balance up when I reviewed the order.
    It would kindly be needed that the order causes reward of points… However, thehe virtual product only gets a status that will trigger the mycred coins to be rewarded to the buyers account automated.
    Does this work?

    I can confirm that your snippet works perfect here on my end.
    Checked the test orders and marked as completed and immediately the buyers account is charged.

    … but automisation… where can we hook it into ?

    #15205
    Avatar
    WPExperts

    yes, you can not automate the manual gateways, they rely on you informing them when a payment is completed. The same goes for myCRED. It relies on specific instances to occur in WooCommerce in order to know when to pay out.

    #15206
    Avatar
    Andre

    ok. lemme talk back with my partners

    #17504
    Avatar
    technique

    Hello, Im back…
    this is mssg i get when trying to activate a custom plugin with the code referenced in your post above

    Plugin could not be activated because it triggered a fatal error.

    Fatal error: Cannot redeclare mycred_pro_adjust_woo_rewards() (previously declared in /home/evidentro/public_html/innergye.tk/wp-content/themes/gameplan/functions.php:852) in /home/evidentro/public_html/innergye.tk/wp-content/plugins/Adjust myCRED Point Rewards/Adjust myCRED Point Rewards.php on line 15

    using myCred 1.6.4 I would greatly appreciate some guidance on how I can get the scripting correct

    thanks 4 a great plugin and your supporting it

    #17627
    Avatar
    WPExperts

    @technique. As the error message states, you have code in your theme’s functions.php file that you pasted in which conflicts with the plugin. Please remove the code in your theme’s functions.php file in order for the plugin to take over and run.

Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic.

11