Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with WooCommerce Payment Gateway Roles #9

Merged
merged 1 commit into from
Jul 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions MPM/mpm_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,28 @@ public function get_title()
*/
public function gateways_add_dynamic($gateways)
{
// Add payment gateways, but only if we're about to pay...
if (is_checkout() || is_ajax())
{
if ($this->get_option('enabled') === 'yes' && get_option('woocommerce_currency', 'unknown') === 'EUR')
{
// Add as much gateways as we have payment methods (they will claim their own indices)
for ($i = count($this->get_methods()); $i > 0; $i--)
{
$gateways[] = 'MPM_Gateway';
}
// This is a settings menu and we'll use the settings class instead
if (is_admin()) {
$screen = get_current_screen();

// Add the settings object as gateway to make it appear in the gateway settings menu
if($screen->id == "woocommerce_page_wc-settings") {
$gateways[] = 'MPM_Settings';

return $gateways;
}
}
else // ...Otherwise, this is a settings menu and we'll use the settings class instead

// Otherwise ... add payment gateways
if ($this->get_option('enabled') === 'yes' && get_option('woocommerce_currency', 'unknown') === 'EUR')
{
// Add the settings object as gateway to make it appear in the gateway settings menu
$gateways[] = 'MPM_Settings';
// Add as much gateways as we have payment methods (they will claim their own indices)
for ($i = count($this->get_methods()); $i > 0; $i--)
{
$gateways[] = 'MPM_Gateway';
}
}

return $gateways;
}

Expand Down