// 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( '#
});
// 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 );
Gradina – Pagina 14 – Bitsmart
Sari la conținut
-
Autentificare
-
Înregistrare
„VENTILATOR PICIOR CU TIMER TEESA” a fost adăugat în coș.
Vezi coșul
Afișez 209 - 224 din 1736 de rezultate
-

Descriere:Celebrele baterii Varta High Energy…
-

Descriere:Baterie alcalina VARTA, marime LR06.…
-

Descriere:Mărime: AAA Referință IEC: LR03…
-

Descriere:Baterie alcalina, marime LR06 (AA),…
-

Descriere:Baterie alcalină, mărime LR06, marca…
-

Descriere:Baterie alcalina, marime LR06 (AA),…
-

Descriere:Mărime: AA Referință IEC: LR6…
-

Descriere:Baterie alcalină, 1.5 V, mărime…
-

Descriere:Mărime: C Referință IEC: LR14…
-

Descriere:Baterie alcalina marime LR14, Maxpower…
-

Descriere:Baterie alcalina Maxell, marime LR03…
-

Descriere:Baterie alcalina Maxell, marime LR14…
-

Descriere:Bateria alcalină, mărime LR9V, Panasonic…
-

Descriere:Baterie alcalina REBEL, marime C…
-

Descriere:Baterie pentru proteze auditive, Duracell…
-

Descriere:Baterie auditiva Duracell HA312. Sistem…