// Google Customer Reviews Opt-in pe pagina de confirmare comandă WooCommerce
add_action('woocommerce_thankyou', function($order_id) {
if (!$order_id) return;
$order = wc_get_order($order_id);
if (!$order) return;
$email = $order->get_billing_email();
$country = $order->get_shipping_country();
$delivery_date = date('Y-m-d', strtotime($order->get_date_created()->format('Y-m-d') . ' +3 days'));
// GTIN pentru fiecare produs (dacă există)
$products = [];
foreach ($order->get_items() as $item) {
$product = $item->get_product();
if (!$product) continue;
$gtin = $product->get_meta('gtin');
if (!$gtin) {
$gtin = $product->get_meta('_wpm_gtin_code');
if (!$gtin) $gtin = $product->get_meta('_woo_gtin_code');
}
if ($gtin) {
$products[] = [ 'gtin' => $gtin ];
}
}
$js_products = !empty($products) ? ', "products": ' . json_encode($products) : '';
echo '';
echo '';
echo '';
echo '';
});
if ( ! defined( 'WP_DEBUG' ) ) {
die( 'Direct access forbidden.' );
}
// Debug: confirmăm că functions.php al child-theme-ului este încărcat
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( '[DEBUG] Child-theme functions.php loaded at ' . date( 'Y-m-d H:i:s' ) );
}
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style(
'child-style',
get_stylesheet_uri(),
[ 'parent-style' ],
wp_get_theme()->get( 'Version' )
);
});
// Optimizări homepage: reducem render-blocking în critical path
add_action( 'wp_head', function() {
if ( ! ( is_front_page() || is_home() ) ) return;
// Inline CSS critic (nu așteptam download)
echo '';
// Preconnect Google Fonts
echo '';
echo '';
echo '';
}, 2 );
// Desktop homepage: nu încărcăm Facebook Pixel
add_action( 'template_redirect', function() {
if ( ! ( is_front_page() || is_home() ) ) return;
ob_start( function( $html ) {
$html = preg_replace( '##is', '', $html );
$html = preg_replace( '##is', '', $html );
return $html;
} );
}, 1 );
// Homepage: facem imaginea LCP discoverable imediat (fără lazy, cu fetchpriority=high)
add_filter( 'wp_get_attachment_image_attributes', function( $attr, $attachment ) {
static $lcp_assigned = false;
if ( $lcp_assigned ) {
return $attr;
}
if ( ! ( is_front_page() || is_home() ) ) {
return $attr;
}
if ( ! $attachment || empty( $attachment->ID ) ) {
return $attr;
}
$custom_logo_id = (int) get_theme_mod( 'custom_logo' );
if ( $custom_logo_id && (int) $attachment->ID === $custom_logo_id ) {
return $attr;
}
$meta = wp_get_attachment_metadata( (int) $attachment->ID );
$width = isset( $meta['width'] ) ? (int) $meta['width'] : 0;
$height = isset( $meta['height'] ) ? (int) $meta['height'] : 0;
if ( $width < 480 || $height < 320 ) {
return $attr;
}
$attr['fetchpriority'] = 'high';
$attr['loading'] = 'eager';
$attr['decoding'] = 'async';
$lcp_assigned = true;
return $attr;
}, 10, 2 );
// Homepage: CSS non-critic în preload async (agresiv pe mobil)
add_filter( 'style_loader_tag', function( $html, $handle, $href, $media ) {
if ( is_admin() || is_customize_preview() ) return $html;
if ( ! ( is_front_page() || is_home() ) ) return $html;
// Stabilitate > micro-optimizări: evităm transformarea stylesheet-urilor în preload+onload,
// deoarece poate lăsa pagina fără CSS la anumiți utilizatori/browsere.
return $html;
}, 10, 4 );
add_filter( 'script_loader_tag', function( $tag, $handle, $src ) {
if ( is_admin() || is_customize_preview() ) return $tag;
if ( ! ( is_front_page() || is_home() ) ) return $tag;
if ( ! $src ) return $tag;
// Safety first: only defer a strict allowlist of non-critical frontend scripts.
// WordPress core/Elementor scripts often print inline "-js-after" blocks that
// execute immediately and break when the external script is deferred.
$defer_allowlist = [
'souracebuster-js-js',
'wc-order-attribution-js',
'blocksy-ext-cookies-consent-scripts-js',
'ht_ctc_main_js',
];
if ( ! in_array( $handle, $defer_allowlist, true ) ) return $tag;
// Check if already deferred/async
if ( strpos( $tag, ' defer' ) !== false || strpos( $tag, ' async' ) !== false ) return $tag;
// Defer only allowlisted scripts.
return str_replace( '
});
// 3. Salvează tipul client în meta comandă
add_action( 'woocommerce_checkout_create_order', function( $order, $data ) {
$post_data = [];
if ( isset( $_POST['post_data'] ) ) {
parse_str( wp_unslash( $_POST['post_data'] ), $post_data );
} else {
$post_data = $_POST;
}
if ( isset( $post_data['client_type'] ) ) {
$client_type = sanitize_text_field( wp_unslash( $post_data['client_type'] ) );
$order->update_meta_data( '_client_type', $client_type );
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( '[Facturare] Client type salvat: ' . $client_type );
}
}
}, 10, 2 );
// 4. Validare PF/PJ la checkout
add_action( 'woocommerce_after_checkout_validation', function( $posted_data, $errors ) {
if ( ! isset( $posted_data['client_type'] ) ) return;
$client_type = sanitize_text_field( wp_unslash( $posted_data['client_type'] ) );
if ( $client_type === 'pj' ) {
if ( empty( $posted_data['billing_company'] ) ) {
$errors->add( 'billing_company_required', 'Denumire firmă este obligatorie pentru persoane juridice.' );
}
if ( empty( $posted_data['billing_cui'] ) ) {
$errors->add( 'billing_cui_required', 'CUI/CIF este obligatoriu pentru persoane juridice.' );
}
} else {
if ( empty( $posted_data['billing_first_name'] ) || empty( $posted_data['billing_last_name'] ) ) {
$errors->add( 'billing_name_required', 'Numele și prenumele sunt obligatorii.' );
}
}
}, 10, 2 );
// 5. Afișează tip client în emailuri
add_filter( 'woocommerce_email_order_meta_fields', function( $fields, $sent_to_admin, $order ) {
$client_type = $order->get_meta( '_client_type' );
if ( $client_type ) {
$fields['client_type'] = [
'label' => 'Tip Client',
'value' => $client_type === 'pj' ? 'Persoană Juridică' : 'Persoană Fizică',
];
}
return $fields;
}, 10, 3 );
// Adăugăm H1 SEO pentru homepage și pagina de shop.
add_action( 'blocksy:content:top', function() {
if ( is_admin() ) {
return;
}
if ( is_front_page() || is_home() ) {
echo '
BitSmart - Sisteme fotovoltaice și soluții de energie verde pentru acasă și business
';
return;
}
if ( function_exists( 'is_shop' ) && is_shop() ) {
echo 'Shop BitSmart - Panouri fotovoltaice, invertoare, baterii și accesorii
';
}
}, 5 );
// Dezactivează sidebar-ul din shop/categorie/tag pagini (inclusiv widgetul "Cele mai căutate")
add_action( 'wp', function() {
if ( ! function_exists( 'is_shop' ) || ! function_exists( 'is_product_category' ) || ! function_exists( 'is_product_tag' ) ) {
return;
}
if ( is_shop() || is_product_category() || is_product_tag() ) {
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
}
} );
// Meta description pentru homepage (SEO).
add_action( 'wp_head', function() {
if ( ! is_front_page() && ! is_home() ) {
return;
}
echo '' . "\n";
}, 1 );
// Schema.org structured data pentru Organization (SEO & AI indexing)
add_action( 'wp_head', function() {
if ( ! is_front_page() && ! is_home() ) return;
$schema = [
'@context' => 'https://schema.org',
'@type' => 'Organization',
'name' => get_bloginfo( 'name' ),
'url' => home_url(),
'logo' => get_site_icon_url( 512 ),
'description' => get_bloginfo( 'description' ),
'sameAs' => [
// Adaugă link-uri social media aici
],
];
echo '' . "\n";
}, 1 );
// Schema.org pentru produse WooCommerce (automat de Rank Math, dar adăugăm fallback)
add_action( 'wp_head', function() {
if ( ! is_product() ) return;
$product_id = get_queried_object_id();
if ( ! $product_id || ! function_exists( 'wc_get_product' ) ) {
return;
}
$product = wc_get_product( $product_id );
if ( ! $product || ! is_a( $product, 'WC_Product' ) ) {
return;
}
// Verificăm dacă Rank Math deja a adăugat schema
if ( function_exists( 'rank_math' ) ) return;
$schema = [
'@context' => 'https://schema.org',
'@type' => 'Product',
'name' => $product->get_name(),
'description' => wp_strip_all_tags( $product->get_short_description() ),
'image' => wp_get_attachment_url( $product->get_image_id() ),
'sku' => $product->get_sku(),
'offers' => [
'@type' => 'Offer',
'price' => $product->get_price(),
'priceCurrency' => 'RON',
'availability' => $product->is_in_stock() ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
'url' => get_permalink( $product->get_id() ),
],
];
if ( $product->get_rating_count() > 0 ) {
$schema['aggregateRating'] = [
'@type' => 'AggregateRating',
'ratingValue' => $product->get_average_rating(),
'reviewCount' => $product->get_rating_count(),
];
}
echo '' . "\n";
}, 1 );
Clesti/Patenti – Pagina 5 – Bitsmart
Sari la conținut
-
Autentificare
-
Înregistrare
„HAND GRIP 0-14KG REBEL ACTIVE” a fost adăugat în coș.
Vezi coșul
Afișez 65 - 80 din 1736 de rezultate
-

Descriere:• Antena auto pentru marcile…
-

Descriere:Antena de masina omnidirecţională pentru…
-

Descriere:Antena de masina AM /…
-

Descriere:- Frecventa: 26-28MHz – S.W.R:…
-

Descriere:Frecventa: 27 – 28.5 MHz…
-

Descriere:- Frecventa: 26 – 28…
-

Descriere:Gama de frecvente: VHF, UHF,…
-

Descriere:Antenă de 42 dB cu…
-

Descriere:Numărul și forma vafelor: 4…
-

Descriere:CARACTERISTICI PRINCIPALE Indicator alimentare Indicator…
-

Descriere:Caracteristici principale Pentru utilizare ca…
-

Descriere:Aparat de vidat alimente Mesko…
-

Descriere:PARAMETRII PRINCIPALI AI PRODUSULUI: •…
-

Descriere:• 2 dimensiuni de cuburi…
-

Descriere:Bateria Li-Ion de 3,6 V…
-

Descriere:Redați hainelor dumneavoastră aspectul inițial…