Last active
July 18, 2023 19:27
-
-
Save somewherewarm-snippets/945bbe317ecb4ad7f26166bc655f582b to your computer and use it in GitHub Desktop.
Use this snippet to remove the 'Apply Gift Card' form on the cart/checkout pages.
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 - Remove the 'Apply Gift Card' form on the cart/checkout pages. | |
* Plugin URI: https://woocommerce.com/products/gift-cards/ | |
* Description: Use this snippet to remove the 'Apply Gift Card' form on the cart/checkout pages. | |
* Version: 1.1 | |
* Author: WooCommerce | |
* Author URI: https://woocommerce.com/ | |
* Developer: Jason Kytros | |
* | |
* | |
* Copyright: © 2021 Automattic | |
* License: GNU General Public License v3.0 | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
add_action( 'init', 'remove_gc_actions' ); | |
function remove_gc_actions() { | |
if ( version_compare( WC_GC()->get_plugin_version( true ), '1.7.0' ) > 0 ) { | |
// Cart | |
// To hide the Gift Cards form from the cart in v1.7+, navigate to WooCommerce > Settings > Gift Cards and disable "Enable cart page features". | |
// Checkout | |
remove_action( 'woocommerce_review_order_before_payment', array( WC_GC()->cart, 'display_form' ), 9 ); | |
} else { | |
// Cart. | |
remove_action( 'woocommerce_proceed_to_checkout', array( WC_GC()->cart, 'display_form' ), 9 ); | |
// Checkout. | |
remove_action( 'woocommerce_review_order_before_submit', array( WC_GC()->cart, 'display_form' ), 9 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer seems to work, is there an updated snippet I've missed?