Repository Forums Support WooCommerce Extended Coupon Features PRO Filter Coupons by Product Tags

Topic Resolution: Resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #3720
    chris6
    Participant

    I have a client that wants to offer coupons based on product tags. We use tags on products in order to reduce the number of product categories customers have to search through. So categories define broad groups of products and tags are used to drill down to more specific topics. I can’t find a way to use tags though in the Pro version of the plugin. I tried the custom fields operator but don’t see product tags as an option, which is surprising because just about everything else is in there.

    Is there a way for me to add product tags to the code?

    Thanks
    Chris Blair

    #3721
    Soft79
    Keymaster

    You can use the following filter:

    add_filter( 'woocommerce_coupon_is_valid_for_product', 
      function ( $valid, $product, $coupon, $values )
      {
        //Make $valid true or false depending on the conditions...
    
        return $valid;
      }, 10, 4 );
    

    And program accordingly.

    #3727
    chris6
    Participant

    I keep getting a fatal error with that code:

    syntax error, unexpected ‘woocommerce_coupon_is_valid_fo’ (T_STRING), expecting ‘(‘

    Tried with my limited PHP to fix but couldn’t seem to get it right.

    Chris

    #3728
    chris6
    Participant

    Also, where will I see tags as an option, in the custom fields dropdown??

    Thanks
    Chris

    #3729
    Soft79
    Keymaster

    This is not a complete solution; logic has to been programmed in. You need a developer for that.
    I edited the snippet in my previous post; indeed it had a syntax error; but you still need someone to program the logic.

    Please, contact us through the contact form if you want a quote for this customization.

    #3732
    chris6
    Participant

    ahh..gotcha. I figured out the syntax error but out of curiosity, why are tags excluded from the custom fields option?

    Chris Blair

    #3733
    Soft79
    Keymaster

    Because tags and custom fields are not related and are stored in a different way.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.