Last active
December 11, 2015 12:38
-
-
Save growdev/4601948 to your computer and use it in GitHub Desktop.
Detecting version of WooCommerce for Payment Gateways to make them compatible with WC 2.0
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 | |
/* | |
* Use this in __construct() to set appropriate options update | |
*/ | |
if ( preg_match('/1\.[0-9]*\.[0-9]*/', WOOCOMMERCE_VERSION )){ | |
// 1.*.* | |
add_action('woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options')); | |
} else { | |
// 2.*.* | |
add_action('woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options')); | |
} | |
/* | |
* Use this in the process_payment() method to clear the awaiting payment flag | |
*/ | |
// Empty awaiting payment session | |
if ( preg_match('/1\.[0-9]*\.[0-9]*/', WOOCOMMERCE_VERSION )){ | |
unset($_SESSION['order_awaiting_payment']); | |
} else { | |
unset( $woocommerce->session->order_awaiting_payment ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Know that now. I like getting my regex on!