• Resolved stoaufik

    (@stoaufik)


    Hi,

    Love the way your plugin works. One thing i badly need is to exclude applying coupons to sales items because we already have sales on some items and we don’t want to provide more discounts on those sales items, how can i do it?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support CartFlows Team

    (@cartflows)

    Hello @stoaufik,

    Thank you for reaching out to us.

    We have added the filter to exclude the products and all the options that coupons have.
    ?
    Here is the custom code through which you can exclude the products and update other parameters.
    ?

    add_filter(‘woo_ca_generate_coupon’, ‘update_coupon_options’);

    function update_coupon_options( $coupon_post_data ){

    $coupon_post_data[‘exclude_product_ids’] = ‘1,2’;

    return $coupon_post_data;
    }
    ?
    ?
    This parameter will apply to all the coupons of different email templates.

    Please add the above code in the function.php file of the child theme.
    ?
    ?
    Let us know if you have any questions.

    Thread Starter stoaufik

    (@stoaufik)

    Hi,

    thanks for the awesome reply.

    One question, do i have to add the products ids to this code,

    ex: $coupon_post_data[‘exclude_product_ids’] = ‘44,45’;

    or i have to add those codes as you provided?

    Thanks.

    Plugin Support CartFlows Team

    (@cartflows)

    Hello,

    You have to update the products id’s in the code. The id’s in the code, i.e., 1,2, are the example.

    Let us know if you have any questions.

    How would I modify this to exclude product categories rather than specific items?

    Plugin Support CartFlows Team

    (@cartflows)

    Hello @eecwrmed,

    You can use the ‘excluded_product_categories’ key to exclude the specific product category.

    Your code snippet will look like this.

    add_filter('woo_ca_generate_coupon', 'update_coupon_options');
    
    function update_coupon_options( $coupon_post_data ){
    
    $coupon_post_data['excluded_product_categories'] = array('your product category');
    
    return $coupon_post_data;
    }
    Thread Starter stoaufik

    (@stoaufik)

    Hi,

    I get this error when i paste this code in functions.php

    Parse error: syntax error, unexpected ‘,’ in /home/customer/www/rxremediesinc.com/public_html/wp-content/themes/rx-remediesinc/functions.php on line 165

    Plugin Support CartFlows Team

    (@cartflows)

    Hello,

    Please refer to the below code.

    add_filter('woo_ca_generate_coupon', 'update_coupon_options');
    
    function update_coupon_options( $coupon_post_data ){
    
        $coupon_post_data['excluded_product_categories'] = array('your product category IDs. separated by comma');
    
        return $coupon_post_data;
    }
    

    Let us know how it goes.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Exclude coupon for sales items’ is closed to new replies.