Repository › Forums › Support › WooCommerce Extended Coupon Features PRO › Obtain coupon info › Reply To: Obtain coupon info
November 1, 2016 at 12:41 pm
#745
Soft79
Keymaster
Hi,
the product id’s are retrieved using this call: get_post_meta( $coupon_id, '_wjecf_free_product_ids', true )
. It will go through the filter apply_filters( "get_{$meta_type}_metadata", null, $object_id, $meta_key, $single );
in wp-includes/post.php.
So you can probably use the following snippet to manipulate the product ids:
add_filter( 'get_post_metadata', 'my_get_post_metadata', 10, 4 );
function my_get_post_metadata ( $meta_value, $object_id, $meta_key, $single ) {
if ( $meta_key == '_wjecf_free_product_ids' ) {
//EXAMPLE: replace the product id by 123
$meta_value = 123;
}
return $meta_value;
}
You can use $object_id to retrieve the WC_Coupon object. (It’s the coupon id)