mycred_get_woo_product_reward

Description

This function will retrieve the amount of points a WooCommerce product is set to reward when purchased, or an array of point types with their associated values if more than one point type exists. Supports both single or variable product types.

This function is only available if myCRED and WooCommerce is installed and enabled on your site!

Available since version 1.7.6

Returns

(bool) FALSE if the product ID is invalid, an array of the reward setup for all point types or the point value in string form when used to retrieve a particular point type.

Parameters

Param Type Required Description
function mycred_get_woo_product_reward(
$product_id int Yes

The WooCommerce product post object ID.

$variation_id int No

Should be set to NULL if the product is not a variable product, otherwise the variations numeric ID.

$requested_type bool or string No

Use FALSE to retrieve values for multiple point types in a associative array format or provide the point type key to retrieve the value for a particular type.

) { ... }

Examples

Example 1: Basic usage example where we show how much points a product rewards (if set).