ModeEffect / subscriber-discounts-for-woocommerce

GNU General Public License v2.0
2 stars 2 forks source link

Custom Coupon #3

Closed GiannisRallis closed 3 years ago

GiannisRallis commented 3 years ago

Hello thank you for the plugin works grate. I want to make a custom coupon code but the function.php code you have provide not work as i expected. It creates a prefix word+random letters. I want to send the exact word how to do that with function.php?

ScottDeLuzio commented 3 years ago

@GiannisRallis in the example code provided in the plugin documentation, I intentionally left the random letters after the prefix word. The reason why is because if you only return the exact word, it will return that same word as the discount code for every user. WooCommerce doesn't need dozens of the same coupon code to work. Actually when you manually try to create multiple coupons with the same code, WooCommerce gives this warning message: image

In your case, I don't think you need this plugin. I would suggest that you create one coupon code manually with either a far out or no expiration date. Then use the built-in "welcome email" sequence in your email provider (i.e. Mailchimp or Active Campaign) to send them the coupon code after they subscribe.

If you really want to use this plugin with it returning the same exact word as the coupon code each time you would do it like this:

function example_custom_discount_code( $discount, $email_address ){
    // Add your company name as a prefix to the discount code:
    $new_code = 'MyCompanyName';
    return $new_code;
}
add_filter( 'sdwoo_discount_code', 'example_custom_discount_code', 10, 2 );

Although, I really don't recommend this method.

GiannisRallis commented 3 years ago

Thank you very much for such fast response. You are right i have to discuss with my client for that. Thank you for the suggestion.