Voici mon code:fonction de rappel WooCommerce est pas appelé
add_action('plugins_loaded', 'mojo_abc_init', 0);
function mojo_abc_init() {
...
include_once('woocommerce-abc.php');
...
add_filter('woocommerce_payment_gateways', 'mojo_add_abc_gateway');
function mojo_add_abc_gateway($methods) {
$methods[] = 'MOJO_ABC';
return $methods;
}
...
}
Mon fichier WooCommerce-abc.php:
class MOJO_ABC extends WC_Payment_Gateway{
function __construct() {
...
add_action('woocommerce_api_mojo_abc', array($this, 'check_abc_response'));
...
}
/* callback function */
function check_abc_response(){
/* code */
wp_die();
}
}
Maintenant, mon problème est ma fonction de rappel n'est pas appelé. L'URL est http://site_url/wc-api/MOJO_ABC. À la place, l'écran affiche seulement 1 et rien dans les journaux de débogage n'indique également un problème avec le code.
Toute aide serait grandement appréciée. Merci
Je voudrais essayer d'initialiser votre plugin sur le crochet 'woocommerce_loaded'. Mais aussi, ajoutez-vous votre passerelle via le filtre 'woocommerce_available_payment_gateways'? Vous n'avez pas montré cette partie de votre code. – helgatheviking
@helgatheviking J'ajoute ma passerelle via le filtre 'woocomerce_available_payment_gateways'. J'ai modifié le code. En tout cas j'ai été capable de résoudre le problème. –
Pourriez-vous poster votre solution en réponse? – helgatheviking