1

I am looking to add the function, where I can offer a user a discount code that affects their next subscription amount.

For example:

  • I give customer code 1234 to give them 10% off their next months renewal
  • They enter the code in their My Account area and then Stripe knows that next month to charge them 10% less then the usual amount.

I have seen a few questions on here asking something similar but no answers so thought I would ask myself and see if anyone can offer their assistance.

James Deadman
  • 191
  • 2
  • 2
  • 15
  • Have you read the guide on subscription coupons with Woocommerce? It looks to be exactly what you're after: https://docs.woocommerce.com/document/subscriptions/store-manager-guide/?_ga=2.196148652.1013478205.1604587664-2071328294.1603126887#section-9 – ttmarek Nov 05 '20 at 15:01
  • 1
    Hi, yes I have been through that. By default you are only allowed to add a coupon from the start of a subscription. Ie a reoccurring one or an initial discount. I am talking about adding one when someone already has a subscription so it acts as a discount on their next months renewal – James Deadman Nov 06 '20 at 10:47
  • @JamesDeadman have you found a solution? – filipecsweb Aug 04 '21 at 20:13

1 Answers1

1

This is what worked for me. The coupon has a discount type of Recurring Product % Discount and it applies on the next renewal(s) . You can set for how many renewals it is applied to. The code to apply it is:

$subscription->apply_coupon('your-coupon-code');

And I use it like this on the form handler:

if(isset($_POST['sid']) && $_POST['sid'] != ""){
            $subscription = wcs_get_subscription( $_POST['sid'] );
            if($subscription->get_status()=="active"){
                $subscription->apply_coupon($_POST['coupon']); // returns true on success
            }
        }
Kim A.
  • 21
  • 2