Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi @anish9947,

    Thank you for reaching out.

    To set a maximum discount amount for a percentage coupon, follow these steps:

    1. Navigate to WooCommerce > Coupons.

    2. Click “Add Coupon” or edit an existing one.

    3. Under “Coupon data”, select “Percentage Discount” from the dropdown.

    4. Enter the percentage in the “Coupon amount” field.

    5. In the “Usage Restriction” section, fill in the “Maximum spend” field with the maximum amount that can be discounted using the coupon.

    Remember to save your changes. Now, your percentage coupon will not apply a discount greater than the maximum spend limit you’ve set.

    I hope this helps.

    Hello @anish9947

    Thank you for reaching out.

    I appreciate your efforts in addressing the issue. I believe the suggestion below may help provide a solution for setting a maximum limit on percentage-based coupons in WooCommerce:

    Install a plugin like WooCommerce Advanced Coupons or Discount Rules for WooCommerce. These plugins allow you to set a maximum discount limit.

    Here’s how to do it with Discount Rules for WooCommerce:

    1. Install and activate the Discount Rules for WooCommerce plugin.
    2. Go to WooCommerce > Woo Discount Rules.
    3. Create a new rule for percentage-based discounts.
    4. In the rule creation settings, you can define both the percentage discount and the maximum discount amount.
    Thread Starter anish9947

    (@anish9947)

    @ckadenge and @proshantamr

    Thanks for your support.

    Can you please share any custom code for this?

    Hello @anish9947

    Thank you for your interest in this matter. I’m glad to provide a solution that I hope will address your requirement.
    This code will ensure that a maximum discount limit is applied to a specific coupon in WooCommerce.


    add_action( 'woocommerce_cart_calculate_fees', 'set_maximum_discount_limit', 10, 1 );
    function set_maximum_discount_limit( $cart ) {
    // Replace with your coupon code
    $coupon_code = 'YOUR_COUPON_CODE';
    // Set the maximum discount amount (in your currency)
    $max_discount = 50;

    if ( ! is_admin() && ! defined( 'DOING_AJAX' ) ) {
    foreach( $cart->get_applied_coupons() as $coupon ) {
    if( $coupon === $coupon_code ) {
    $discount = $cart->get_coupon_discount_amount( $coupon_code );
    if( $discount > $max_discount ) {
    $cart->remove_coupon( $coupon_code );
    $cart->add_fee( __( 'Maximum discount reached', 'woocommerce' ), -$max_discount );
    }
    }
    }
    }
    }

    Thread Starter anish9947

    (@anish9947)

    Hello @proshantamr

    Thanks for your reply,

    I checked with you provided code but it’s not working in checkout page. I request you please check and let me know.

    Hello @anish9947

    Thank you for your interest.

    Please note that the code can be applied on the Cart page. Make sure to apply the code before proceeding to checkout. If you need assistance with applying the code on the Checkout page, please reach out to the WooCommerce Community on Slack. Thank you.

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @anish9947

    Please note that writing or providing custom code is not within the scope of our support policy. If you are still having problems, we recommend asking development questions on the #developers channel of the WooCommerce Community Slack. Many of our developers hang out there and will be able to offer insights into your question. You can also seek help from the following:

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

    Thread Starter anish9947

    (@anish9947)

    Hello,

    I request you anyone please help me with custom code.

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi @anish9947,

    This is a fairly complex development topic.

    I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend you visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

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