Created
May 30, 2019 00:54
-
-
Save helgatheviking/9150d64b000353c18beeadb8aa375083 to your computer and use it in GitHub Desktop.
WooCommerce Coupon Redemption Form Shortcode
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: WC Coupon Redemption Form Shortcode | |
* Plugin URI: https://kathyisawesome.com/ | |
* Description: Display coupon form with [fgc_form] shortcode | |
* Version: 1.0.0 | |
* Author: Kathy Darling | |
* Author URI: https://kathyisawesome.com | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
/** | |
* Shortcode to enter gift code | |
*/ | |
function fgc_gift_claim_form() { | |
if ( function_exists( 'wc_coupons_enabled' ) && wc_coupons_enabled() ) { ?> | |
<form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post"> | |
<div class="actions"> | |
<div class="coupon"> | |
<label for="coupon_code"><?php esc_html_e( 'Coupon:', 'your-text-domain' ); ?></label> | |
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'your-text-domain' ); ?>" /> | |
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Claim free gift', 'your-text-domain' ); ?>"><?php esc_attr_e( 'Claim Free Gift', 'your-text-domain' ); ?></button> | |
<?php do_action( 'woocommerce_cart_coupon' ); ?> | |
</div> | |
</div> | |
</form> | |
<?php } ?> | |
<?php | |
} | |
add_shortcode( 'fgc_form', 'fgc_gift_claim_form' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment