Les hooks pour le tunnel et le panier de WooCommerce.

Ajouter un lien de suppression des articles dans le récapitulatif de commande du tunnel d’achat

PHP
                    <?php 
function undfnd_add_remove_link_on_product_checkout($product_name, $cart_item, $cart_item_key) {
    if (is_checkout()) {
        $product_name .= apply_filters('woocommerce_cart_item_remove_link', sprintf(
            '<a href="%s" rel="nofollow" class="remove">' . __('Remove this item', 'woocommerce') . '</a>',
            esc_url(WC_Cart::get_remove_url($cart_item_key)),
            __('Remove this item', 'woocommerce'),
            esc_attr($cart_item['product_id']),
            esc_attr($cart_item['data']->get_sku())
        ), $cart_item_key);
        return $product_name;
    }
    return $product_name;
}
add_action( 'woocommerce_cart_item_name', 'undfnd_add_remove_link_on_product_checkout', 10, 3 );
                

Supprimer le champs téléphone dans le tunnel d’achat

PHP
                    <?php 
function undfnd_woocommerce_checkout_fields( $fields ) {
    unset( $fields['billing']['billing_phone'] );
    return $fields;
}
add_action( 'woocommerce_checkout_fields', 'undfnd_woocommerce_checkout_fields' );
                

Modifier le texte du bouton de commande

PHP
                    <?php 
function undfnd_woocommerce_order_button_text() {
    return __('Commander', 'domain_lang');
}
add_action( 'woocommerce_order_button_text', 'undfnd_woocommerce_order_button_text' );
                

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