Plugin admin dashboards empty
-
Hi,
we use the following code snippets to filter payment and shipping methods, which when in functions.php enabled, create a conflict with your plugin. The plugin admin dashboards stay empty and do not load anything. Any suggestion or code correction would be appreciated.
// /**
// * ==================================================================================
// * WooCommerce Disable Payment Gateway for a Specific Country
// * ==================================================================================
// */
function ts_disable_payment_gateway_by_country($available_payment_gateways)
{
global $woocommerce;
if (is_admin()) return $available_payment_gateways;
if (WC()->customer->get_billing_country() == 'CY') {
if (isset($available_payment_gateways['bacs'])) {
unset($available_payment_gateways['bacs']);
}
if (isset($available_payment_gateways['cheque'])) {
unset($available_payment_gateways['cheque']);
}
if (isset($available_payment_gateways['cod'])) {
unset($available_payment_gateways['cod']);
}
}
return $available_payment_gateways;
}
add_filter('woocommerce_available_payment_gateways', 'ts_disable_payment_gateway_by_country'); // /**
// * ==================================================================================
// * @snippet Disable Other Payment Gateways If Local Pickup Shipping Method Chosen
// * ==================================================================================
// */
function gateway_disable_shipping_326($available_gateways)
{
if (!is_admin()) {
$chosen_methods = WC()->session->get('chosen_shipping_methods');
$chosen_shipping = $chosen_methods[0];
if (0 === strpos($chosen_shipping, 'local_pickup')) {
unset($available_gateways['cod']);
//unset( $available_gateways['cop'] );
unset($available_gateways['bacs']);
}
}
return $available_gateways;
}
add_filter('woocommerce_available_payment_gateways', 'gateway_disable_shipping_326');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Plugin admin dashboards empty’ is closed to new replies.