/** * EINHELL SOLO PROMOCIJA * * Svaka 2 SOLO uređaja daju pravo na * 1 aku bušilicu ID 23512 za 1 KM. * * Kupac sam dodaje bušilicu u košaricu. */ function cdp_cart_is_available() { return function_exists('WC') && WC()->cart instanceof WC_Cart; } /** * POSTAVKE PROMOCIJE */ function cdp_promo_config() { return [ 'drill_id' => 23512, 'solo_tag' => 'solo', 'required' => 2, 'price' => 1.00, ]; } /** * BROJANJE SOLO UREĐAJA */ function cdp_get_solo_product_count() { if (!cdp_cart_is_available()) { return 0; } $config = cdp_promo_config(); $count = 0; foreach (WC()->cart->get_cart() as $item) { $product_id = (int) $item['product_id']; $variation_id = (int) ( $item['variation_id'] ?? 0 ); // Promotivni artikli ne daju pravo na popust. if (in_array($product_id, [ 23512, 25109, 313453 ], true)) { continue; } $is_solo = has_term( $config['solo_tag'], 'product_tag', $product_id ); if (!$is_solo && $variation_id) { $is_solo = has_term( $config['solo_tag'], 'product_tag', $variation_id ); } if ($is_solo) { $count += (int) $item['quantity']; } } return $count; } /** * BROJ PROMOTIVNIH BUŠILICA U KOŠARICI */ function cdp_get_drill_count() { if (!cdp_cart_is_available()) { return 0; } $count = 0; foreach (WC()->cart->get_cart() as $item) { if ((int) $item['product_id'] === 23512) { $count += (int) $item['quantity']; } } return $count; } /** * BROJ BUŠILICA S PRAVOM NA POPUST */ function cdp_allowed_discount_count() { $config = cdp_promo_config(); return intdiv( cdp_get_solo_product_count(), $config['required'] ); } /** * OBRAČUN PROMOTIVNE CIJENE */ add_action( 'woocommerce_before_calculate_totals', 'cdp_apply_custom_pricing', 1000 ); add_action( 'woocommerce_cart_loaded_from_session', 'cdp_apply_custom_pricing', 1000 ); function cdp_apply_custom_pricing($cart) { if (is_admin() && !wp_doing_ajax()) { return; } if (!$cart instanceof WC_Cart || $cart->is_empty()) { return; } $config = cdp_promo_config(); $remaining = cdp_allowed_discount_count(); // Originalna cijena iz kataloga. $drill = wc_get_product($config['drill_id']); if (!$drill || $drill->get_price('edit') === '') { return; } $normal_price = (float) $drill->get_price('edit'); foreach ($cart->get_cart() as $key => $item) { if ((int) $item['product_id'] !== $config['drill_id']) { continue; } $qty = (int) $item['quantity']; if ($qty <= 0) { continue; } $discounted_qty = min($remaining, $qty); $normal_qty = $qty - $discounted_qty; // Prosječna cijena kada dio količine // ima popust, a ostatak redovnu cijenu. $unit_price = ( ($discounted_qty * $config['price']) + ($normal_qty * $normal_price) ) / $qty; $product = clone $item['data']; $product->set_price($unit_price); $cart->cart_contents[$key]['data'] = $product; $cart->cart_contents[$key]['cdp_discounted_qty'] = $discounted_qty; $cart->cart_contents[$key]['cdp_normal_qty'] = $normal_qty; $cart->cart_contents[$key]['cdp_normal_price'] = $normal_price; $remaining -= $discounted_qty; } } /** * RAZLOŽENA CIJENA U KOŠARICI */ add_filter( 'woocommerce_cart_item_price', 'cdp_custom_cart_item_price', 10, 3 ); function cdp_custom_cart_item_price($html, $item, $key) { if ((int) $item['product_id'] !== 23512) { return $html; } $d = (int) ($item['cdp_discounted_qty'] ?? 0); $r = (int) ($item['cdp_normal_qty'] ?? 0); if ($d <= 0) { return $html; } $config = cdp_promo_config(); $normal_price = (float) ( $item['cdp_normal_price'] ?? 0 ); $parts = []; if ($d > 0) { $price = wc_get_price_to_display( $item['data'], ['price' => $config['price']] ); $parts[] = $d . ' × ' . wc_price($price); } if ($r > 0) { $price = wc_get_price_to_display( $item['data'], ['price' => $normal_price] ); $parts[] = $r . ' × ' . wc_price($price); } return '' . implode('
', $parts) . '
'; } /** * BROJ KOMADA ISPOD NAZIVA U KOŠARICI */ add_filter( 'woocommerce_cart_item_name', 'cdp_custom_cart_item_name', 10, 3 ); function cdp_custom_cart_item_name($name, $item, $key) { if ( (int) $item['product_id'] === 23512 && (int) $item['quantity'] > 0 ) { $name .= '
' . (int) $item['quantity'] . ' komada'; } return $name; } /** * CIJENA NA STRANICI PROIZVODA */ add_filter( 'woocommerce_get_price_html', 'cdp_custom_price_html', 1000, 2 ); function cdp_custom_price_html($html, $product) { if ((int) $product->get_id() !== 23512) { return $html; } if (!cdp_cart_is_available()) { return $html; } $allowed = cdp_allowed_discount_count(); $in_cart = cdp_get_drill_count(); if ($allowed <= $in_cart) { return $html; } $normal = $product->get_price('edit'); if ($normal === '') { return $html; } $config = cdp_promo_config(); $regular_display = wc_get_price_to_display( $product, ['price' => (float) $normal] ); $promo_display = wc_get_price_to_display( $product, ['price' => $config['price']] ); return wc_format_sale_price( $regular_display, $promo_display ) . $product->get_price_suffix(); } /** * SALE BADGE "AKCIJA" */ add_filter( 'woocommerce_sale_flash', 'cdp_custom_sale_badge', 10, 3 ); function cdp_custom_sale_badge($html, $post, $product) { if ((int) $product->get_id() !== 23512) { return $html; } if (!cdp_cart_is_available()) { return ''; } $allowed = cdp_allowed_discount_count(); $in_cart = cdp_get_drill_count(); if ($allowed > $in_cart) { return 'Akcija'; } return ''; } Guma 215/40R18 89W XL FR ASC 2 AllSeasonContact 2 CONTINENTAL | Kupite online | eKutak.ba

Guma 215/40R18 89W XL FR ASC 2 AllSeasonContact 2 CONTINENTAL

Besplatna dostava

Izvorna cijena bila je: 399.00 KM.Trenutna cijena je: 318.00 KM.

8 na zalihi

💳Plaćanje: Gotovinom pri preuzimanju, internet bankarstvom, karticama jednokratno i na rate
↩️Povrat robe: Moguće unutar 15 dana
Monri Secure
MastercardMaestroVisaAmerican Express
Sigurno kartično plaćanje
Redovna cijena:318.00 KM
Kartice 6 rata:već od58.30 KM/mj
Kartice 12 rata:već od29.15 KM/mj
Kartice 24 rate:već od14.58 KM/mj
EU lager
Dostupne po narudžbi, Isporuka 10–15 dana.
SKU: 03201530000-2Oznake: ,