woocommerce_flat_rate_shipping_add_rate

ACTION woocommerce\includes\shipping\legacy-flat-rate\class-wc-shipping-legacy-flat-rate.php (ligne 277) github
Developers can add additional flat rates based on this one via this action since @version 2.4. Previously there were (overly complex) options to add additional rates however this was not user. friendly and goes against what Flat Rate Shipping was originally intended for. This example shows how you can add an extra rate based on this flat rate via custom function:      add_action( 'woocommerce_flat_rate_shipping_add_rate', 'add_another_custom_flat_rate', 10, 2 );

Paramètres

Entrée :
$this, $rate
Sortie :
N/A

Utilisation

// Ajouter une fonction au hook action 'woocommerce_flat_rate_shipping_add_rate'
add_action('woocommerce_flat_rate_shipping_add_rate', 'ma_fonction_personnalisee', 10, 1);

function ma_fonction_personnalisee($this, $rate) {
    // Votre code ici
    error_log('Hook woocommerce_flat_rate_shipping_add_rate déclenché');
}

Actualités

Chargement des actualités...