Repository Forums Support WooCommerce Extended Coupon Features PRO Restriction for a product attribute Reply To: Restriction for a product attribute



back with this request. I think I managed to make this working, but I had to modify the plugin core.

Please give feedback and if you know a better solution (using hooks or something) to achieve this I would like to know.


I have a product attribute called with the slug tip-produs (product type in english) for which I have the following terms: full-size, trial-size (these are the slugs)

I have these applied to certain product variations. For example: On a product one variation has the full-size, the other variation has the trial-size. Similar like you would have a shirt with red and blue color.

Modifications I did in core:

includes/pro/WJECF_Pro_Product_Filter.php on the get_all_custom_fields function

I modified this: WHERE p.post_type = 'product' to WHERE p.post_type = 'product' OR p.post_type = 'product_variation'

for the product_matches_custom_field function (same file) instead of using $metavalue = WJECF_Wrap( $product )->get_meta( $cf['key'], true ); I used $metavalue = get_post_meta( WJECF_Wrap( $product )->get_id(), $cf['key'], true);

Coupon setup:

– percent discount: 10
– minimum value: 30
– custom fields: attribute_pa_tip-produs (name) full-size (value)