This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Gift Cards | |
* Plugin URI: https://woocommerce.com/products/gift-cards/ | |
* Description: Use this snippet to set a specific expiration date for all gift cards created on your store | |
* Version: 1.0 | |
* Author: WooCommerce | |
* Author URI: https://woocommerce.com/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2020 Jason Kytros | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_filter( 'woocommerce_gc_create_order_giftcard_args', 'sw_gc_set_custom_expiry_date', 10, 4 ); | |
function sw_gc_set_custom_expiry_date( $args, $_product, $order_item, $order ) { | |
$base = 0 === $args['deliver_date'] ? time() : $args['deliver_date']; | |
$base_datetime = new DateTime(); | |
// year, month, date. | |
$base_datetime->setDate( '2021', '10', '10' ); | |
$args[ 'expire_date' ] = $base_datetime->getTimestamp(); | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment