• Resolved verticaiberia

    (@verticaiberia)


    Hello,
    Is it possible to activate discounts for a buyer via an affiliate link? That is, an affiliate link activates an automatic discount when a purchase is made through that link without having to use coupons.
    Thank you!

Viewing 1 replies (of 1 total)
  • Plugin Author iova.mihai

    (@iovamihai)

    Hey @verticaiberia,

    Thank you for reaching out! I’m afraid that this cannot be done without coupons.

    We do have a code snippet that works with a coupon however. I know you were looking for a non-coupon way, however, as this isn’t possible, going the coupon route is the next best thing. If you’re open to this option, please use this code snippet:

    function slicewp_custom_apply_general_coupon_on_checkout() {
    	
    	$code = 'code_to_apply';
    	
    	if ( ! function_exists( 'is_cart' ) || ! function_exists( 'is_checkout' ) ) {
    		return;
    	}
    	
    	if ( ! is_cart() && ! is_checkout() ) {
    		return;
    	}
    	
    	if ( ! function_exists( 'slicewp_get_referrer_affiliate_id' ) ) {
    		return;
    	}
    	
    	$affiliate_id = slicewp_get_referrer_affiliate_id();
    	
    	if ( empty( $affiliate_id ) ) {
    		return;
    	}
    	
    	if ( ! slicewp_is_affiliate_valid( $affiliate_id ) ) {
    		return;
    	}
    	
    	if ( WC()->cart->has_discount( $code ) ) {
    		return;
    	}
    
    	WC()->cart->apply_coupon( $code );
    
    }
    add_action( 'template_redirect', 'slicewp_custom_apply_general_coupon_on_checkout' );

    Please copy the code and add it to your website. If you’re not sure how to add code snippets to your site, you can use the Code Snippets plugin (https://www.ads-software.com/plugins/code-snippets/).

    This will require you to create a coupon, which will then be added to the cart/checkout if the visit is an affiliate referred one.

    Please make sure to replace the “code_to_apply” string with your own coupon’s code.

    Thank you and best wishes,

    Mihai

Viewing 1 replies (of 1 total)
  • The topic ‘Buyer discounts on affiliate links’ is closed to new replies.