• Resolved d555555

    (@d555555)


    Hi,

    What is the best action/filter I can use for applying a custom coupon restriction?

    I want to limit the maximum discount per usage according to the current user role. What would you recommend so I don’t mess up your plugin’s remaining credit logic and other restrictions logic?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @d555555,

    Greetings from WebToffee Support!

    Currently, the Smart Coupon For WooCommerce plugin utilizes the WooCommerce filter woocommerce_coupon_get_discount_amount to provide the maximum discount value.

    If you wish to implement a custom coupon restriction and limit the maximum discount per usage based on the current user role, we recommend utilizing the WooCommerce filter woocommerce_coupon_get_discount_amount. This filter allows you to modify the discount amount calculated by WooCommerce before it is applied.

    By using this filter, you can add your custom logic to check the current user’s role and adjust the maximum discount accordingly. This will allow you to implement your specific coupon restriction without interfering with our plugin’s other restrictions or logic.

    If you have any further questions or need assistance with the implementation, feel free to let us know. We are here to help.

    Thread Starter d555555

    (@d555555)

    Thank you! I’ve tried that, but if I update the cart totals and discounts directly within this filter, it doesn’t seem to carry on with the rest of your logic – remaining credits, smart_coupon_contribution, etc.

    Any suggestions?

    Also, do you have an email where I can contact you directly in case you are interested/available for freelance work?

    Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @d555555,

    Thank you for the update, and we appreciate your efforts in trying to implement the custom coupon restriction. Regarding your concern about updating cart totals and discounts within the woocommerce_coupon_get_discount_amount filter, it’s important to note that directly modifying cart totals and discounts within this filter might indeed interfere with the standard logic of other plugins using this filter, including Smart Coupon for WooCommerce. If the customization you have provided is the last one hooked and altered the previous calculations, then your calculations will take precedence and get reflected in the cart.

    To provide a more effective solution, we recommend an alternative approach. Instead of directly updating cart totals and discounts within the woocommerce_coupon_get_discount_amount filter, consider using this filter only to adjust the maximum discount amount based on user roles. For other customizations, you can explore additional WooCommerce hooks and filters that are more specific to the functionalities you want to modify.

    Regarding freelance opportunities, we appreciate your inquiry. However, at the moment, we don’t engage in any freelance work and hence don’t have a dedicated email for such inquiries. We hope you understand.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom coupon restrictions’ is closed to new replies.