Appliquer un code promo via un paramètre de l’URL.

PHP
                    <?php 
function undfnd_woocommerce_coupon_links(){
    // Bail if WooCommerce or sessions aren't available.
    if (!function_exists('WC') || !WC()->session) {
        return;
    }
    /**
     * Filter the coupon code query variable name.
     *
     * @since 1.0.0
     *
     * @param string $query_var Query variable name.
     */
    $query_var = apply_filters('woocommerce_coupon_links_query_var', 'coupon_code');
    // Bail if a coupon code isn't in the query string.
    if (empty($_GET[$query_var])) {
        return;
    }
    // Set a session cookie to persist the coupon in case the cart is empty.
    WC()->session->set_customer_session_cookie(true);
    // Apply the coupon to the cart if necessary.
    if (!WC()->cart->has_discount($_GET[$query_var])) {
        // WC_Cart::add_discount() sanitizes the coupon code.
        WC()->cart->add_discount($_GET[$query_var]);
    }
}
add_action( 'wp_loaded', 'undfnd_woocommerce_coupon_links', 30, 1 );
                

Paramètre coupon_code