Skip to content

Instantly share code, notes, and snippets.

@popforce
Last active March 21, 2024 06:16
Show Gist options
  • Save popforce/7775948a9adba3258cb1889a7b56ca48 to your computer and use it in GitHub Desktop.
Save popforce/7775948a9adba3258cb1889a7b56ca48 to your computer and use it in GitHub Desktop.
Fix Memory Exhaustion for WooCommerce Point of Sale 5.5.4 by Actuality Exentsions + WPML in WP 6.4.3 / WC 8.7.0
<?php
/*
Line 310: Prevent PHP memory exhaustion while using translations by calling get_available_payment_gateways once
and not over and over.
*/
function wc_pos_get_available_payment_gateways() {
static $available_gateways = null;
if ($available_gateways === null) {
global $woocommerce;
$wc_gateways = $woocommerce->payment_gateways()->get_available_payment_gateways();
$available_gateways = array();
foreach ($wc_gateways as $gateway) {
$available_gateways[] = (object) array(
'id' => $gateway->id,
'title' => $gateway->get_title(),
);
}
}
return $available_gateways;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment