Documentation

Customizing personalized customer coupons

There are some filters intended for advanced users which you can use for example to change the default coupon prefix or the coupon code length. You'll find some basic usage examples below.

Change the default coupon prefix#

All unique coupons generated by ShopMagic have an sm- prefix by default. If you want to change the default prefix, use the code below:
add_filter( 'shopmagic/coupon/default_prefix', 'sm_custom_default_coupon_prefix' );
/**
* Change the default coupon prefix
*
* @return string
*/
function sm_custom_default_coupon_prefix() {
return 'abc-';
}

Change the coupon code length#

By default, the generated coupons are 10 characters long (plus the prefix). In order to change the length, use the code below:
add_filter( 'shopmagic/coupon/code_length', 'sm_custom_coupon_length' );
/**
* Change the coupon code length
*
* @return int
*/
function sm_custom_coupon_length() {
return 20;
}

Override the coupon code#

If you want to entirely override the generated code (for example by creating your own generator function), you can use the code below:
add_filter( 'shopmagic/coupon/code', 'sm_custom_coupon_code' );
/**
* @param string $code
*
* @return string
*/
function sm_custom_coupon_code( $code ) {
return md5( $code );
}

Not the solution you are looking for?

Please check other articles or open a support ticket.

Cookies preferences

Others

Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.

Necessary

Necessary
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.

Advertisement

Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.

Analytics

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.

Functional

Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.

Performance

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.