Buyer discounts on affiliate links

[ad_1]

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://projectdmc.org/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

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer