Ask your WordPress questions! Pay money and get answers fast! (more info)

Smart Coupon by Woothemes for Woocommerce WordPress

  • REFUNDED

How do I get expiry date on the email sent after purchase of gift certificate?

I am using smart coupon on my website to sell gift certificate/ store credit

When I send a gift certificate to someone they receive the Coupon code but I want expiry date as well displayed on email.

And also I want to remove the blue box with coupon detail from the email. I just want to display a coupon code and expiry date like a plain text.

Also I need the value / price of the gift certificate displayed.

I am using the Smart coupon email template.

Thanks

Answers (3)

2015-04-28

Arnav Joy answers:

Hi ,
Can you show us your site ? and also the email user gets ?

2015-04-28

Romel Apuya answers:

Use your own email template in place of the default one provided by Smart Coupons.
1.Create a template file and keep the file name as: email.php. Other file names will not work.
2. Open your themes folder and create new folder. Keep the folder’s name as: woocommerce-smart-coupons
3. Place file email.php inside woocommerce-smart-coupons
4. The file path of your email template should be: /wp-content/themes/your-theme-folder/woocommerce-smart-coupons/email.php
Smart Coupons will use your template file (if found) for all emails sent from Smart Coupons.

code in the email.php on your theme would be this below

<?php if (!defined('ABSPATH')) exit; ?>
<?php
if ( function_exists( 'wc_get_template' ) ) {
wc_get_template('emails/email-header.php', array( 'email_heading' => $email_heading ));
} else {
woocommerce_get_template('emails/email-header.php', array( 'email_heading' => $email_heading ));
}
?>
<?php echo $message_from_sender; ?>
<p><?php echo sprintf(__("To redeem your discount use the following coupon code during checkout:", 'wc_smart_coupons'), $blogname); ?></p>

<?php
$coupon_target = '';
$wc_url_coupons_active_urls = get_option( 'wc_url_coupons_active_urls' );
if ( !empty( $wc_url_coupons_active_urls ) ) {
$coupon = get_page_by_title( strtolower( $coupon_code ), 'ARRAY_A', 'shop_coupon' );
$coupon_target = ( !empty( $wc_url_coupons_active_urls[ $coupon['ID'] ]['url'] ) ) ? $wc_url_coupons_active_urls[ $coupon['ID'] ]['url'] : '';
}
if ( !empty( $coupon_target ) ) {
$coupon_target = home_url( '/' . $coupon_target );
} else {
$coupon_target = home_url( '/?sc-page=shop&coupon-code=' . $coupon_code );
}
?>
<strong style="margin: 10px 0; font-size: 2em; line-height: 1.2em; font-weight: bold; display: block; text-align: center;" title="<?php echo __( 'Click to apply', 'wc_smart_coupons' ); ?>">
<a href="<?php echo $coupon_target; ?>" style="text-decoration: none; color: hsl(0, 0%, 45%);">
<?php echo $coupon_code; ?>
</a>
</strong>
<div>
<?php
$expiry_date = get_post_meta( $coupon['ID'], 'expiry_date', true );
?>
Expiry Date: <?php echo $expiry_date?>
</div>
<center><a href="<?php echo $url; ?>"><?php echo sprintf(__("Visit store",'wc_smart_coupons') ); ?></a></center>
<?php if ( !empty( $from ) ) { ?>
<p><?php echo __( 'You got this gift card', 'wc_smart_coupons' ) . ' ' . $from . $sender; ?></p>
<?php } ?>
<div style="clear:both;"></div>
<?php
if ( function_exists( 'wc_get_template' ) ) {
wc_get_template('emails/email-footer.php');
} else {
woocommerce_get_template('emails/email-footer.php');
}
?>


Amit Baral comments:

Hi Romel,
It's not working it's giving me blank on the expiry date. Sorry :(


Amit Baral comments:

Hi Romel,
It's not working it's giving me blank on the expiry date. Sorry :(


Romel Apuya comments:

how about this one



<?php if (!defined('ABSPATH')) exit; ?>
<?php
if ( function_exists( 'wc_get_template' ) ) {
wc_get_template('emails/email-header.php', array( 'email_heading' => $email_heading ));
} else {
woocommerce_get_template('emails/email-header.php', array( 'email_heading' => $email_heading ));
}
?>
<?php echo $message_from_sender; ?>
<p><?php echo sprintf(__("To redeem your discount use the following coupon code during checkout:", 'wc_smart_coupons'), $blogname); ?></p>
<?php
$coupon_target = '';
$wc_url_coupons_active_urls = get_option( 'wc_url_coupons_active_urls' );
if ( !empty( $wc_url_coupons_active_urls ) ) {
$coupon = get_page_by_title( strtolower( $coupon_code ), 'ARRAY_A', 'shop_coupon' );
$coupon_target = ( !empty( $wc_url_coupons_active_urls[ $coupon['ID'] ]['url'] ) ) ? $wc_url_coupons_active_urls[ $coupon['ID'] ]['url'] : '';
}
if ( !empty( $coupon_target ) ) {
$coupon_target = home_url( '/' . $coupon_target );
} else {
$coupon_target = home_url( '/?sc-page=shop&coupon-code=' . $coupon_code );
}
?>
<strong style="margin: 10px 0; font-size: 2em; line-height: 1.2em; font-weight: bold; display: block; text-align: center;" title="<?php echo __( 'Click to apply', 'wc_smart_coupons' ); ?>">
<a href="<?php echo $coupon_target; ?>" style="text-decoration: none; color: hsl(0, 0%, 45%);">
<?php echo $coupon_code; ?>
</a>

$coupon = new WC_Coupon($coupon_code);
$coupon_data = get_coupon_meta_data( $coupon );
if( !empty( $coupon->expiry_date ) ) {
$expiry_date = get_expiration_format( $coupon->expiry_date );
echo '<div class="coupon-expire">Expiry Date :'. $expiry_date .'</div>';
}else {
echo '<div class="coupon-expire">'. __( 'Never Expires', 'wc_smart_coupons' ) . '</div>';
}

<center><a href="<?php echo $url; ?>"><?php echo sprintf(__("Visit store",'wc_smart_coupons') ); ?></a></center>
<?php if ( !empty( $from ) ) { ?>
<p><?php echo __( 'You got this gift card', 'wc_smart_coupons' ) . ' ' . $from . $sender; ?></p>
<?php } ?>
<div style="clear:both;"></div>
<?php
if ( function_exists( 'wc_get_template' ) ) {
wc_get_template('emails/email-footer.php');
} else {
woocommerce_get_template('emails/email-footer.php');
}
?>


Amit Baral comments:

Sorry. That didn't work either. I had already tried that before. I did again and failed.

2015-04-30

Jayaram Y answers:

Even i tried putting $expiry_date in email.php but was not working. I found this plugin. Please check screenshots. the email they receive has expiry date.

http://codecanyon.net/item/woocommerce-gift-card-pro/10147426

or

http://ignitewoo.com/woocommerce-extensions-plugins-themes/woocommerce-gift-certificates-pro/