This hook allows you to reward your users for buying a WooCommerce product in your store. Unlike other hooks, this hook is setup by editing your products and not on the usual hooks page in your admin area.
Each product you edit, you can select to reward with either one or multiple point types. For variable products, as of version 1.7.6, you can also set a unique amount for each variation.
This hook requires WooCommerce to be installed and enabled.
Edit your product and select the point type(s) you want to reward when the product is purchased and enter a point value.
For variable products, you can still use the myCRED metabox to reward the same amount no matter which variation a user selects, or set a value in each variation.
||Give or take points from users for purchasing a product.|
In the following instances points are NOT going to be paid out:
- The buyer is not logged in when placing an order.
- The buyer is excluded from the point type you set to reward.
- The order was paid with a manual payment gateway (see example 2 below for a fix to this).
- The order was paid using points.
- The product is set to reward zero points.
Example 1: Reward store purchases by paying a percentage of the product price as points to the buyer. The percentage to pay is dictated by the category the product is in.
Example 2: By default myCRED will payout points for WooCommerce orders when an order has been marked as “paid“. This means that no points will be paid out if a users pays using a manual gateway such as Check or Bank Transfers. This code snippet will force myCRED to payout when an order has been marked as “Completed“ instead of paid.
Example 3: Reward store purchases by paying a percentage of the order total as points to the buyer.