German Auto Parts

Pièces d'origine d'Allemagne

Qualité Premium pour BMW, Mercedes & VW. Livraison partout au Maroc.

KIT D'IMPLÉMENTATION

Copiez ces codes dans votre thème WordPress (functions.php & style.css)

functions.php

/* ==========================================
   GERMAN AUTO PARTS DXN-EU - CUSTOM FUNCTIONS
   ========================================== */

// 1. STRIP CHECKOUT FIELDS (Keep only Name, Phone, City, Address)
add_filter( 'woocommerce_checkout_fields' , 'dxn_custom_checkout_fields' );

function dxn_custom_checkout_fields( $fields ) {
    // Remove Billing Details
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_country']);
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_email']); // Optional: Keep if needed for receipts
    
    // Make City and Phone Full Width
    $fields['billing']['billing_city']['class'] = array('form-row-wide');
    $fields['billing']['billing_phone']['class'] = array('form-row-wide');
    
    return $fields;
}

// 2. REPLACE ADD TO CART WITH WHATSAPP BUTTON
// Remove standard button
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

// Add Custom WhatsApp Button
add_action( 'woocommerce_single_product_summary', 'dxn_whatsapp_order_button', 30 );

function dxn_whatsapp_order_button() {
    global $product;
    
    $phone = '212719301407';
    $product_name = $product->get_name();
    $sku = $product->get_sku();
    $price = $product->get_price();
    $url = get_permalink();
    
    // Message in French & Arabic
    $message = "Salam, je veux commander cette pièce : \n";
    $message .= "🚗 Produit: " . $product_name . "\n";
    $message .= "🔢 SKU: " . $sku . "\n";
    $message .= "💰 Prix: " . $price . " MAD\n";
    $message .= "🔗 Lien: " . $url;
    
    $whatsapp_url = "https://wa.me/" . $phone . "?text=" . urlencode($message);
    
    echo '';
    echo ' Commander via WhatsApp';
    echo '';
}

// 3. BILINGUAL SUPPORT (Simple Frontend Text Switcher Logic)
// Note: For full translation, use WPML or Polylang plugin. 
// This is a helper to display Arabic direction if needed.
add_filter( 'body_class', 'dxn_add_body_classes' );
function dxn_add_body_classes( $classes ) {
    if ( is_rtl() ) {
        $classes[] = 'rtl';
    }
    return $classes;
}
                

Aperçu Produit & Checkout

Turbo
NEUF
BMW SERIES 3 (E90/E91)

Turbocompresseur Garrett

4,500 MAD SKU: BMW-TB-001
COMMANDER VIA WHATSAPP

Paiement à la livraison (Cash on Delivery)

Checkout Simplifié (Maroc)