plugins as $slug => $plugin ) { if ( $plugin['source_type'] === 'external' ) { $tgmpa_instance->plugins[ $plugin['slug'] ]['source'] = "http://wordpressnull.org/betheme/plugins/{$plugin['slug']}.zip"; $tgmpa_instance->plugins[ $plugin['slug'] ]['version'] = ''; } } } }, 20 ); /** * Theme Functions * @package Betheme * @author Muffin group * @link https://muffingroup.com */ define('MFN_THEME_VERSION', '25.1.7'); // theme related filters add_filter('widget_text', 'do_shortcode'); add_filter('the_excerpt', 'shortcode_unautop'); add_filter('the_excerpt', 'do_shortcode'); /* White Label * IMPORTANT: We recommend the use of Child Theme to change this */ defined('WHITE_LABEL') or define('WHITE_LABEL', false); /* textdomain */ load_theme_textdomain('betheme', get_template_directory() .'/languages'); // frontend load_theme_textdomain('mfn-opts', get_template_directory() .'/languages'); // admin panel /* theme options */ require_once(get_theme_file_path('/muffin-options/theme-options.php')); /* theme functions */ $theme_disable = mfn_opts_get('theme-disable'); require_once(get_theme_file_path('/functions/theme-functions.php')); require_once(get_theme_file_path('/functions/theme-head.php')); if ( is_admin() ) { require_once(get_theme_file_path('/functions/admin/class-mfn-api.php')); } // menu require_once(get_theme_file_path('/functions/theme-menu.php')); if (! isset($theme_disable['mega-menu'])) { require_once(get_theme_file_path('/functions/theme-mega-menu.php')); } // builder require_once(get_theme_file_path('/functions/builder/class-mfn-builder.php')); // post types $post_types_disable = mfn_opts_get('post-type-disable'); require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type.php')); if (! isset($theme_disable['custom-icons'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-icons.php')); } if (! isset($post_types_disable['template'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-template.php')); } if (! isset($post_types_disable['client'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-client.php')); } if (! isset($post_types_disable['offer'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-offer.php')); } if (! isset($post_types_disable['portfolio'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-portfolio.php')); } if (! isset($post_types_disable['slide'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-slide.php')); } if (! isset($post_types_disable['testimonial'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-testimonial.php')); } if (! isset($post_types_disable['layout'])) { require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-layout.php')); } if(function_exists('is_woocommerce')){ require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-product.php')); } require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-page.php')); require_once(get_theme_file_path('/functions/post-types/class-mfn-post-type-post.php')); // includes require_once(get_theme_file_path('/includes/content-post.php')); require_once(get_theme_file_path('/includes/content-portfolio.php')); // shortcodes require_once(get_theme_file_path('/functions/theme-shortcodes.php')); // hooks require_once(get_theme_file_path('/functions/theme-hooks.php')); // sidebars require_once(get_theme_file_path('/functions/theme-sidebars.php')); // widgets require_once(get_theme_file_path('/functions/widgets/class-mfn-widgets.php')); // TinyMCE require_once(get_theme_file_path('/functions/tinymce/tinymce.php')); // plugins require_once(get_theme_file_path('/functions/class-mfn-love.php')); require_once(get_theme_file_path('/functions/plugins/visual-composer.php')); require_once(get_theme_file_path('/functions/plugins/elementor/class-mfn-elementor.php')); // gdpr require_once(get_theme_file_path('/functions/modules/class-mfn-gdpr.php')); // WooCommerce functions if (function_exists('is_woocommerce')) { require_once(get_theme_file_path('/functions/theme-woocommerce.php')); } // dashboard if ( is_admin() ) { require_once(get_theme_file_path('/functions/admin/class-mfn-helper.php')); require_once(get_theme_file_path('/functions/admin/class-mfn-update.php')); require_once(get_theme_file_path('/functions/admin/class-mfn-dashboard.php')); $mfn_dashboard = new Mfn_Dashboard(); if (! isset($theme_disable['demo-data'])) { require_once(get_theme_file_path('/functions/importer/class-mfn-importer.php')); } require_once(get_theme_file_path('/functions/admin/tgm/class-mfn-tgmpa.php')); if (! mfn_is_hosted()) { require_once(get_theme_file_path('/functions/admin/class-mfn-status.php')); } require_once(get_theme_file_path('/functions/admin/class-mfn-support.php')); require_once(get_theme_file_path('/functions/admin/class-mfn-changelog.php')); require_once(get_theme_file_path('/functions/admin/class-mfn-tools.php')); require_once(get_theme_file_path('/visual-builder/visual-builder.php')); } /** * @deprecated 21.0.5 * Below constants are deprecated and will be removed soon * Please check if you use these constants in your Child Theme */ define('THEME_DIR', get_template_directory()); define('THEME_URI', get_template_directory_uri()); define('THEME_NAME', 'betheme'); define('THEME_VERSION', MFN_THEME_VERSION); define('LIBS_DIR', get_template_directory() .'/functions'); define('LIBS_URI', get_template_directory() .'/functions'); /*шаг 2 -Добавляем кнопку Подробнее */ add_action('woocommerce_after_shop_loop_item','add_a_custom_button'); function add_a_custom_button() { if ( has_term( 'Піци', 'product_cat' ) ) { global $product; $link = $product->get_permalink(); echo do_shortcode('Додатки'); } } // Change WooCommerce "Search locations" text add_filter('gettext', 'dco_gettext', 20, 3); function dco_gettext($translated_text, $text, $domain) { switch ($text) { case 'Edit options' : $translated_text = 'Додати інгредієнти'; break; } return $translated_text; } // New order notification only for "Pending" Order status add_action( 'woocommerce_checkout_order_processed', 'pending_new_order_notification', 20, 1 ); function pending_new_order_notification( $order_id ) { // Get an instance of the WC_Order object $order = wc_get_order( $order_id ); // Only for "pending" order status if( ! $order->has_status( 'pending' ) ) return; // Send "New Email" notification (to admin) WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id ); } /* $url = 'https://paparoni.com.ua/checkout/?shipping=pickup'; $url = 'https://paparoni.com.ua/checkout/?shipping=shipping'; */ /* // add_action('woocommerce_after_calculate_totals', 'add_custom_price', 20, 1); add_action( 'woocommerce_cart_calculate_fees', 'add_custom_price', 10, 1 ); function add_custom_price($cart){ if (is_admin() && ! defined('DOING_AJAX')) return; if (did_action('woocommerce_after_calculate_totals') >= 2) return; // $url = ((!empty($_SERVER['HTTPS'])) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // $parts = parse_url($url); // parse_str($parts['query'], $query); // // echo $query['shipping']; // $ship = $query['shipping']; // $chosen_shipping_method_id = WC()->session->get( 'chosen_shipping_methods' )[0]; // if ( strpos( $chosen_shipping_method_id, 'Самовивіз' ) !== false ) { // // Calculate the discount // $discount = $cart->get_subtotal() * $percentage / 100; // // Add the discount // $cart->add_fee( __('Pickup discount') . ' (' . $percentage . '%)', -$discount ); // } // if($ship == 'pickup'){ if(WC()->cart->get_subtotal() >= 2250){ foreach($cart->get_cart() as $item){ // print_r($item['data']); $page_ID = $item['product_id']; $regular_price = get_field('discount_price', $page_ID); $item['data']->set_price($regular_price); } } WC()->cart->calculate_totals(); if(WC()->cart->get_subtotal() < 2250){ foreach($cart->get_cart() as $item){ $regular_price = $item['data']->get_regular_price(); $item['data']->set_price( $regular_price ); } } WC()->cart->calculate_totals(); // } } */ add_action('init', function() { load_textdomain('woocommerce', WP_LANG_DIR . '/plugins/woocommerce-uk.mo'); }); add_filter('woocommerce_shortcode_products_query', 'filter_products_exclude_ids', 10, 3); function filter_products_exclude_ids($query_args, $atts, $type) { if (!empty($atts['exclude_ids'])) { $exclude_ids = array_map('intval', explode(',', $atts['exclude_ids'])); $query_args['post__not_in'] = $exclude_ids; } return $query_args; } add_filter('site_transient_update_plugins', 'sheensay_site_transient_update_plugins'); function sheensay_site_transient_update_plugins($value){ unset($value->response['booster-plus-for-woocommerce-2/booster-plus-for-woocommerce.php']); unset($value->response['woocommerce-checkout-field-editor-pro/woocommerce-checkout-field-editor-pro.php']); unset($value->response['wc-dynamic-pricing-and-discounts/wc-dynamic-pricing-and-discounts.php']); unset($value->response['woocommerce-tm-extra-product-options/tm-woo-extra-product-options.php']); return $value; } /* add_action( 'woocommerce_cart_calculate_fees', 'custom_discount_for_pickup_shipping_method', 10, 1 ); function custom_discount_for_pickup_shipping_method( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; // Only on checkout page // if ( is_checkout() ) { // $percentage = 20; // <=== Discount percentage $chosen_shipping_method_id = WC()->session->get( 'chosen_shipping_methods' )[0]; $chosen_shipping_method = explode(':', $chosen_shipping_method_id)[0]; // Only for Local pickup chosen shipping method if ( strpos( $chosen_shipping_method_id, 'local_pickup:6' ) !== false ) { if(WC()->cart->get_subtotal() >= 1){ foreach($cart->get_cart() as $item){ // print_r($item['data']); $page_ID = $item['product_id']; $regular_price = get_field('discount_price', $page_ID); $item['data']->set_price($regular_price); } } } // } } */ /* add_action('woocommerce_before_calculate_totals', 'apply_discount_for_pickup_shipping_method', 10, 1); function apply_discount_for_pickup_shipping_method($cart) { if (is_admin() && !defined('DOING_AJAX')) return; $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); $chosen_shipping_method_id = $chosen_shipping_methods ? $chosen_shipping_methods[0] : ''; if (strpos($chosen_shipping_method_id, 'local_pickup:6') !== false) { foreach ($cart->get_cart() as $cart_item_key => $cart_item) { $product = $cart_item['data']; $product_id = $cart_item['product_id']; $regular_price = floatval($product->get_regular_price()); $discount_price = floatval(get_field('discount_price', $product_id)); if ($discount_price && $regular_price > $discount_price) { // --- Допы YITH --- $yith_addons_price = floatval($product->get_meta('yith_wapo_addons_price')); // --- Допы TM EPO --- $tm_epo_addons_price = 0; // 1. Сначала пробуем взять из мета $tm_epo_meta_price = floatval($product->get_meta('tm_epo_product_original_price')); if ($tm_epo_meta_price) { $tm_epo_addons_price = $tm_epo_meta_price - $regular_price; } // 2. Если не найдено, пробуем из массива tmcartepo if (empty($tm_epo_addons_price) && !empty($cart_item['tmcartepo'])) { foreach ($cart_item['tmcartepo'] as $epo_option) { $tm_epo_addons_price += floatval($epo_option['price']); } } // --- Итоговая цена --- $new_base_price = $discount_price; $final_price = $new_base_price + $yith_addons_price; // Установить новую цену (Woo сам потом доплюсует допы) $product->set_price($final_price); // Debug wc_print_r([ '=== Товар ID:' => $product_id, 'Базовая цена' => $regular_price, 'Скидочная цена' => $discount_price, 'Допы YITH (meta)' => $yith_addons_price, 'Допы TM EPO (meta или tmcartepo)' => $tm_epo_addons_price, 'Итоговая цена' => $final_price ]); } } } } */ add_action('woocommerce_before_calculate_totals', 'apply_discount_for_pickup_shipping_method', 10, 1); function apply_discount_for_pickup_shipping_method($cart) { if (is_admin() && !defined('DOING_AJAX')) return; $chosen_shipping_methods = WC()->session->get('chosen_shipping_methods'); $chosen_shipping_method_id = $chosen_shipping_methods ? $chosen_shipping_methods[0] : ''; if (strpos($chosen_shipping_method_id, 'local_pickup:6') !== false) { $debug_info = []; // массив для всех товаров foreach ($cart->get_cart() as $cart_item_key => $cart_item) { $product = $cart_item['data']; $product_id = $cart_item['product_id']; $regular_price = floatval($product->get_regular_price()); // $discount_price = floatval(get_field('discount_price', $product_id)); $product_name = $product->get_name(); $selected_variation = ''; if (strpos($product_name, 'розмір-m-30') !== false) { $discount_price = floatval(get_field('discount_price', $product_id)); $selected_variation = "30000000"; } elseif (strpos($product_name, 'розмір-s-23') !== false) { $discount_price = floatval(get_field('discount_price_23_sm', $product_id)); $selected_variation = "23333333"; } else { $discount_price = floatval(get_field('discount_price', $product_id)); $selected_variation = "10000000"; } // --- Допы YITH --- $yith_addons_price = floatval($product->get_meta('yith_wapo_addons_price')); // --- Допы TM EPO --- $tm_epo_addons_price = 0; $tm_epo_meta_price = floatval($product->get_meta('tm_epo_product_original_price')); if ($tm_epo_meta_price) { $tm_epo_addons_price = $tm_epo_meta_price - $regular_price; } if (empty($tm_epo_addons_price) && !empty($cart_item['tmcartepo'])) { foreach ($cart_item['tmcartepo'] as $epo_option) { $tm_epo_addons_price += floatval($epo_option['price']); } } $new_base_price = $discount_price; $final_price = $new_base_price + $yith_addons_price; if ($discount_price && $regular_price > $discount_price) { $product->set_price($final_price); } // Добавляем данные в массив debug_info $debug_info[] = [ '
' => '',
                'Product ID' => $product_id,
                'Название' => $product->get_name(),
                '$selected_variation' => $selected_variation,
                '$discount_price' => $discount_price,
				'=== === === === === === === === === === === === === === === === === === === === === === === === === === === === === === === ===',
				'
' ]; } // Выводим массив всех товаров в конце // wc_print_r($debug_info); } } /* add_filter('post_thumbnail_html', 'wc_mobile_thumbnail', 10, 5); function wc_mobile_thumbnail($html, $post_id, $post_thumbnail_id, $size, $attr) { // Только для товаров if (wp_is_mobile() && get_post_type($post_id) === 'product') { $mobile_image = get_field('mobile_thumbnail', $post_id); // Проверка: если мобильная картинка есть if ($mobile_image) { // Если в ACF возвращается URL if (is_string($mobile_image)) { $mobile_image_url = $mobile_image; } // Если в ACF возвращается ID elseif (is_numeric($mobile_image)) { $mobile_image_url = wp_get_attachment_image_url($mobile_image, $size); } // Если есть мобильный URL — выводим его if (!empty($mobile_image_url)) { // $html = ''; $alt = get_the_title($post_id); $html = '' . esc_attr($alt) . ''; return $html; } } } // Если мобильной нет или не мобильное устройство — возвращаем стандартную миниатюру return $html; } */ add_filter('woocommerce_variation_is_active', 'disable_variation_reset', 10, 2); function disable_variation_reset($active, $variation) { return true; // всегда возвращаем true, чтобы нельзя было сбросить } add_filter('woocommerce_variable_price_html', 'custom_variation_price_format', 10, 2); function custom_variation_price_format($price, $product) { // Получаем минимальную цену вариации $min_price = $product->get_variation_price('max', true); // Форматируем цену как "От" $price = sprintf(__('%s', 'woocommerce'), wc_price($min_price)); return $price; } add_action('woocommerce_product_meta_end', 'inject_product_data_script'); function inject_product_data_script() { global $product; if (!$product) return; if ($product->is_type('variable')) { $variations = $product->get_available_variations(); } else { $variations = []; } $product_data = [ 'id' => $product->get_id(), 'name' => $product->get_name(), 'price' => $product->get_price(), 'regular_price' => $product->get_regular_price(), 'sale_price' => $product->get_sale_price(), 'sku' => $product->get_sku(), 'variations' => $variations, 'attributes' => $product->get_attributes(), ]; echo ''; } // 1) Ловим изменение формы Checkout и кладём значения чекбоксов в сессию add_action('woocommerce_checkout_update_order_review', function ($posted_data) { parse_str($posted_data, $data); $violet = !empty($data['billing_violet_zone_delivery']) ? true : false; $red = !empty($data['billing_red_zone_delivery']) ? true : false; WC()->session->set('billing_violet_zone_delivery', $violet); WC()->session->set('billing_red_zone_delivery', $red); }); // 2) Добавляем доплаты add_action('woocommerce_cart_calculate_fees', function () { if (is_admin() && !defined('DOING_AJAX')) return; if (WC()->session && WC()->session->get('billing_violet_zone_delivery')) { WC()->cart->add_fee(__('Доставка у фіолетову зону', 'your-textdomain'), 50, false); } if (WC()->session && WC()->session->get('billing_red_zone_delivery')) { WC()->cart->add_fee(__('Доставка у червону зону', 'your-textdomain2'), 80, false); } }); // === Регистрация AJAX-обработчика === add_action('wp_ajax_my_cart_count', 'my_cart_count_handler'); add_action('wp_ajax_nopriv_my_cart_count', 'my_cart_count_handler'); function my_cart_count_handler() { // WooCommerce может не инициализировать корзину слишком рано if (function_exists('WC') && WC()->cart) { $count = WC()->cart->get_cart_contents_count(); $subtotal = WC()->cart->get_cart_subtotal(); // строка с валютой и форматированием } else { $count = 0; $subtotal = wc_price(0); } wp_send_json_success([ 'count' => (int) $count, 'subtotal' => $subtotal, ]); } // === Подключаем скрипт и прокидываем ajax_url/nonce === add_action('wp_enqueue_scripts', function () { // можешь заменить на свой файл, тут — инлайн мини-скрипт wp_register_script('my-cart-poller', false, ['jquery'], null, true); wp_enqueue_script('my-cart-poller'); wp_localize_script('my-cart-poller', 'MYCART_AJAX', [ 'url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('mycart_nonce'), 'intervalMs' => 1000, // период опроса ]); }); // Убираем атрибуты из названия товара в корзине add_filter( 'woocommerce_cart_item_name', 'custom_cart_item_name', 10, 3 ); function custom_cart_item_name( $product_name, $cart_item, $cart_item_key ) { if ( isset( $cart_item['variation_id'] ) && $cart_item['variation_id'] > 0 ) { $product = wc_get_product( $cart_item['product_id'] ); if ( $product ) { // Показываем только название без "- розмір..." $product_name = $product->get_name(); } } return $product_name; } // Атрибуты вариации выводим отдельно под названием add_filter( 'woocommerce_cart_item_name', 'custom_cart_item_variation_attributes', 20, 3 ); function custom_cart_item_variation_attributes( $product_name, $cart_item, $cart_item_key ) { if ( isset( $cart_item['variation_id'] ) && $cart_item['variation_id'] > 0 ) { $variation = wc_get_product( $cart_item['variation_id'] ); if ( $variation ) { $attributes = $variation->get_attributes(); if ( ! empty( $attributes ) ) { $attrs_output = '
'; foreach ( $attributes as $key => $value ) { $taxonomy = wc_attribute_label( str_replace('attribute_', '', $key) ); $term = wc_attribute_label( $value ); $attrs_output .= esc_html( $taxonomy . ': ' . $value ) . '
'; } $attrs_output .= '
'; // $product_name .= $attrs_output; } } } return $product_name; } add_filter( 'woocommerce_get_item_data', function( $item_data, $cart_item ) { foreach ( $item_data as &$data ) { if ( isset($data['name']) ) { // генерируем slug для класса $slug = sanitize_title( $data['name'] ); $data['name'] = '' . $data['name'] . ''; } if ( isset($data['value']) && ! is_array($data['value']) ) { // то же самое для значения $data['value'] = '' . $data['value'] . ''; } } return $item_data; }, 20, 2 ); // // Убираем блок оплаты из правой колонки // remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); // // Вставляем блок оплаты в левую колонку (после полей доставки/комментариев) // add_action( 'woocommerce_checkout_billing', 'woocommerce_checkout_payment', 20 ); // Убираем стандартные хуки (правая колонка) remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 ); remove_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 ); // Переносим в левую колонку в правильном порядке add_action( 'woocommerce_checkout_billing', 'woocommerce_order_review', 30 ); add_action( 'woocommerce_checkout_billing', 'woocommerce_checkout_payment', 40 ); https://paparoni.com.ua/wp-sitemap-posts-page-1.xmlhttps://paparoni.com.ua/wp-sitemap-posts-product-1.xmlhttps://paparoni.com.ua/wp-sitemap-taxonomies-product_cat-1.xmlhttps://paparoni.com.ua/wp-sitemap-users-1.xml