Task 7715 | исправлено отображение цен доставки на цену с учетом НДС

pull/39/head
parent cbc6e74957
commit 893472a4b9
  1. 2
      wp-content/themes/cosmopet/global-functions/multisite-functions.php
  2. 12
      wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php
  3. 4
      wp-content/themes/cosmopet/modules/profile/components/subscription_single/component-controller.php
  4. 2
      wp-content/themes/cosmopet/modules/profile/components/subscriptions/component-controller.php
  5. 40
      wp-content/themes/cosmopet/temp-functions/woocommerce-logic.php
  6. 4
      wp-content/themes/cosmopet/views/shop/review-order.twig
  7. 10
      wp-content/themes/cosmopet/woocommerce/cart/cart-shipping.php
  8. 2
      wp-content/themes/cosmopet/woocommerce/checkout/review-order.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);
})

@ -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',
];

@ -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,

@ -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'),

@ -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() {

@ -26,8 +26,10 @@
{% if not chosen_shipping_methods[0] is defined %}
<td class="order-your-calculation__description">{{ fn('pll_e', 'Введите адрес доставки') }}</td>
{% else %}
<td class="order-your-calculation__value order-your-calculation__value--price">{{ fn('WC').cart.get_shipping_total() }} ₽</td>
<td class="order-your-calculation__value order-your-calculation__value--price">{{ (fn('WC').cart.get_shipping_total() + fn('WC').cart.get_shipping_tax())|round }} ₽</td>
{% endif %}
</tr>
{% for fee in fn('WC').cart.get_fees() %}

@ -93,9 +93,13 @@ $calculator_text = '';
</div>
<div class="modal-map-control-item__description">
<p class="modal-map-control-item__time"><?php echo $text_in_parentheses; ?></p>
<p class="modal-map-control-item__price"> <?php
echo $method->cost;
?>₽</p>
<p class="modal-map-control-item__price">
<?php
$tax_total = array_sum($method->get_taxes());
echo round($method->cost + $tax_total);
echo get_woocommerce_currency_symbol();
?>
</p>
</div>
<?php do_action( 'woocommerce_after_shipping_rate', $method, $index ); ?>
</div>

@ -64,7 +64,7 @@ defined( 'ABSPATH' ) || exit;
<?php
else:
?>
<td class="order-your-calculation__value order-your-calculation__value--price"><?php echo WC()->cart->get_shipping_total(); ?></td>
<td class="order-your-calculation__value order-your-calculation__value--price"><?php echo WC()->cart->get_shipping_total() + WC()->cart->get_shipping_tax() ?> <?php echo get_woocommerce_currency_symbol(); ?></td>
<?php endif; ?>
</tr>

Loading…
Cancel
Save