• Resolved S3Bubble

    (@s3bubble)


    Hi All,

    I need to have a discount code to allow the first month of a subscription half price.

    The only way i can think to do this is to hook into the apply discount code and then switch products to one that has a trial period 1 month and discount half price applied.

    I cant find a hook to listen to when somebody applies a certain discount code if it matches then update the cart with a discounted product.

    https://shopplugin.net/api/category/develop

    Is there a hook available for this thanks

    https://www.ads-software.com/plugins/shopp/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chris Runnells

    (@crunnells)

    There’s no need for a hook since it’s just a post variable. Just hook a function to the ‘shopp_cart_request’ action, and check for the presence of $_REQUEST[‘discount’]. Then check the discount code entered against your specific discount code, and do the product swap from there.

    Thread Starter S3Bubble

    (@s3bubble)

    Chris your a legend cheers

    Full working code below.

    function shopp_switch_product () {
    
        if($_REQUEST['discount'] == 'firstmonth'){
            shopp_empty_cart();
            // get my product
            $Product = shopp_product('Subscription First Month Half Price', 'name');
    
            // Add quantity 2 of My Product to the cart
            shopp_add_cart_product($Product->id, 1);
        }
    }
    add_action('shopp_cart_request', 'shopp_switch_product');

    Plugin Author Chris Runnells

    (@crunnells)

    Marking this issue resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hook to listen to coupon code applied’ is closed to new replies.