diff --git a/wp-content/themes/cosmopet/global-functions/multisite-functions.php b/wp-content/themes/cosmopet/global-functions/multisite-functions.php index 8e96018..3971657 100644 --- a/wp-content/themes/cosmopet/global-functions/multisite-functions.php +++ b/wp-content/themes/cosmopet/global-functions/multisite-functions.php @@ -35,4 +35,4 @@ add_filter('timber/twig', function (\Twig\Environment $twig) { add_filter('woocommerce_currency_symbol', function($currency_symbol, $currency) { return $currency === 'AED' ? 'AED' : $currency_symbol; -}, 10, 2); \ No newline at end of file +}) \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php b/wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php index 5c11d9e..7f8013d 100644 --- a/wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php +++ b/wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php @@ -276,7 +276,7 @@ function send_order_data($order_id) { $customer_name = $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(); $customer_phone = $order->get_billing_phone(); $customer_email = $order->get_billing_email(); - $order_total = $order->get_total(); + $order_total = round_price_with_tax($order->get_total()); $order_comment = ''; $utm = get_utm_data()['utm_source']; $url = ''; @@ -288,7 +288,7 @@ function send_order_data($order_id) { // Используем get_total_tax() + get_total() для получения полной цены с НДС $item_total_without_tax = $item->get_total(); $item_tax = $item->get_total_tax(); - $item_total_with_tax = round($item_total_without_tax + $item_tax); + $item_total_with_tax = round_price_with_tax($item_total_without_tax + $item_tax); $order_comment .= sprintf( "%s x %s = %s\n", $product->get_name(), @@ -303,7 +303,7 @@ function send_order_data($order_id) { $order_comment .= "\n=== ПРОМОКОДЫ ===\n"; foreach ($coupons as $coupon_code) { $coupon = new WC_Coupon($coupon_code); - $discount_amount = round($order->get_discount_total()); + $discount_amount = round_price_with_tax($order->get_discount_total()); $order_comment .= "Промокод: {$coupon_code}\n"; $order_comment .= "Скидка: " . strip_tags(wc_price($discount_amount)) . "\n"; } @@ -360,7 +360,7 @@ function send_order_data($order_id) { $product_qty = $item->get_quantity(); $product_total_without_tax = $item->get_total(); $product_tax = $item->get_total_tax(); - $product_total_with_tax = round($product_total_without_tax + $product_tax); + $product_total_with_tax = round_price_with_tax($product_total_without_tax + $product_tax); $product_sku = $product->get_sku(); $formData["PRODUCT_{$product_index}_NAME"] = $product_name; @@ -386,7 +386,7 @@ function send_order_data($order_id) { $product_summary .= "=== ПРОМОКОДЫ ===\n"; foreach ($coupons as $coupon_code) { $coupon = new WC_Coupon($coupon_code); - $discount_amount = round($order->get_discount_total()); + $discount_amount = round_price_with_tax($order->get_discount_total()); $product_summary .= "Промокод: {$coupon_code}\n"; $product_summary .= "Скидка: " . strip_tags(wc_price($discount_amount)) . "\n"; } @@ -443,7 +443,7 @@ function notify_order_paid($order_id) { 'TITLE' => 'Заказ #' . $order_id . ' оплачен', 'ORDER_ID' => $order_id, 'PAYMENT_METHOD' => $order->get_payment_method_title(), - 'ORDER_TOTAL' => $order->get_total(), + 'ORDER_TOTAL' => round_price_with_tax($order->get_total()), 'SOURCE' => 'WooCommerce', ]; diff --git a/wp-content/themes/cosmopet/modules/profile/components/subscription_single/component-controller.php b/wp-content/themes/cosmopet/modules/profile/components/subscription_single/component-controller.php index ed0fc4f..a67f019 100644 --- a/wp-content/themes/cosmopet/modules/profile/components/subscription_single/component-controller.php +++ b/wp-content/themes/cosmopet/modules/profile/components/subscription_single/component-controller.php @@ -69,7 +69,7 @@ if (!$subscription || !wcs_is_subscription($subscription) || $subscription->get_ 'variation_details' => $variation_details, ], 'quantity' => $item->get_quantity(), - 'total' => $item->get_total(), + 'total' => round_price_with_tax($item->get_total()), ]; }, $subscription->get_items()); @@ -93,7 +93,7 @@ if (!$subscription || !wcs_is_subscription($subscription) || $subscription->get_ 'last_order_date' => $subscription->get_date('last_order_date_created'), 'next_payment_date' => $subscription->get_date('next_payment'), 'payment_method_title' => $subscription->get_payment_method_title(), - 'total' => $subscription->get_total(), + 'total' => round_price_with_tax($subscription->get_total()), 'currency' => $subscription->get_currency(), 'items' => $items, 'cancel_url' => $cancel_url, diff --git a/wp-content/themes/cosmopet/modules/profile/components/subscriptions/component-controller.php b/wp-content/themes/cosmopet/modules/profile/components/subscriptions/component-controller.php index b31fc70..4e3b2c0 100644 --- a/wp-content/themes/cosmopet/modules/profile/components/subscriptions/component-controller.php +++ b/wp-content/themes/cosmopet/modules/profile/components/subscriptions/component-controller.php @@ -35,7 +35,7 @@ foreach ($subscriptions as $subscription) { $subscription_data[] = [ 'id' => $subscription->get_id(), 'date_created' => $subscription->get_date_created(), - 'total' => $subscription->get_total(), + 'total' => round_price_with_tax($subscription->get_total()), 'currency' => $subscription->get_currency(), 'billing_period' => $subscription->get_billing_period(), 'next_payment_date' => $subscription->get_date('next_payment'), diff --git a/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php b/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php index 23c0d5f..12fa985 100644 --- a/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php +++ b/wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php @@ -174,6 +174,46 @@ function get_collection_siblings($term) { add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); +// Функция для округления цен с учетом налога +function round_price_with_tax($price) { + return round($price); +} + +// Функция для получения цены товара с учетом налога и округления +function get_product_price_with_tax($product) { + if (!$product) return 0; + + $price = $product->get_price(); + $tax_rate = 0; + + // Получаем ставку налога для товара + $tax_rates = WC_Tax::get_rates($product->get_tax_class()); + if (!empty($tax_rates)) { + $tax_rate = array_values($tax_rates)[0]['rate'] ?? 0; + } + + // Вычисляем цену с налогом + $price_with_tax = $price * (1 + $tax_rate / 100); + + return round_price_with_tax($price_with_tax); +} + +// Функция для получения общей суммы корзины с учетом налога и округления +function get_cart_total_with_tax() { + if (!WC()->cart) return 0; + + $total = WC()->cart->get_total('edit'); + return round_price_with_tax($total); +} + +// Функция для получения стоимости доставки с учетом налога и округления +function get_shipping_total_with_tax() { + if (!WC()->cart) return 0; + + $shipping_total = WC()->cart->get_shipping_total(); + return round_price_with_tax($shipping_total); +} + // Добавление поля для выбора рекомендуемых товаров function register_recommended_products_acf_field() { diff --git a/wp-content/themes/cosmopet/views/shop/review-order.twig b/wp-content/themes/cosmopet/views/shop/review-order.twig index 1917942..cce858b 100644 --- a/wp-content/themes/cosmopet/views/shop/review-order.twig +++ b/wp-content/themes/cosmopet/views/shop/review-order.twig @@ -26,8 +26,10 @@ {% if not chosen_shipping_methods[0] is defined %}
cost; - ?>₽
++ get_taxes()); + echo round($method->cost + $tax_total); + echo get_woocommerce_currency_symbol(); + ?> +