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

master
parent f6d97e7c80
commit db88c0ca3d
  1. 24
      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/templates/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

@ -84,7 +84,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
fbq('track', 'ViewContent', {
content_ids: ['<?php echo $product->get_id(); ?>'],
content_type: 'product',
value: <?php echo $product->get_price(); ?>,
value: <?php echo round_price_with_tax($product->get_price()); ?>,
currency: '<?php echo get_woocommerce_currency(); ?>'
});
});
@ -153,7 +153,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
<script>
document.addEventListener('DOMContentLoaded', function() {
fbq('track', 'AddPaymentInfo', {
value: <?php echo $cart_total; ?>,
value: <?php echo round_price_with_tax($cart_total); ?>,
currency: '<?php echo $currency; ?>'
});
@ -162,7 +162,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
'event': 'add_payment_info',
'ecommerce': {
'currency': '<?php echo $currency; ?>',
'value': <?php echo $cart_total; ?>
'value': <?php echo round_price_with_tax($cart_total); ?>
}
});
});
@ -184,7 +184,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
$items[] = [
'item_id' => $product->get_id(),
'item_name' => $product->get_name(),
'price' => $product->get_price(),
'price' => round_price_with_tax($product->get_price()),
'quantity' => $item->get_quantity()
];
}
@ -192,7 +192,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
<script>
document.addEventListener('DOMContentLoaded', function() {
fbq('track', 'Purchase', {
value: <?php echo $order->get_total(); ?>,
value: <?php echo round_price_with_tax($order->get_total()); ?>,
currency: '<?php echo $order->get_currency(); ?>',
content_ids: [<?php echo implode(',', array_column($items, 'item_id')); ?>],
content_type: 'product'
@ -203,7 +203,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
'event': 'purchase',
'ecommerce': {
'currency': '<?php echo $order->get_currency(); ?>',
'value': <?php echo $order->get_total(); ?>,
'value': <?php echo round_price_with_tax($order->get_total()); ?>,
'items': <?php echo json_encode($items); ?>
}
});
@ -228,7 +228,7 @@ if ($site_env->site_mode == 'production' && $site_env->site_region == 'ae') {
$items[] = [
'id' => $product->get_id(),
'name' => $product->get_name(),
'price' => $product->get_price(),
'price' => round_price_with_tax($product->get_price()),
'quantity' => $item->get_quantity()
];
}
@ -317,7 +317,7 @@ add_action('wp_head', function() {
$context['product'] = [
'id' => $product->get_id(),
'name' => $product->get_name(),
'price' => floatval($product->get_price()),
'price' => round_price_with_tax(floatval($product->get_price())),
'sku' => $product->get_sku(),
'category' => wp_get_post_terms($product->get_id(), 'product_cat', ['fields' => 'names'])[0] ?? '',
];
@ -327,7 +327,7 @@ add_action('wp_head', function() {
// Страница чекаута - InitiateCheckout
$context['pixel_event_type'] = 'InitiateCheckout';
if (WC()->cart && !WC()->cart->is_empty()) {
$context['cart_total'] = floatval(WC()->cart->get_total('edit'));
$context['cart_total'] = round_price_with_tax(floatval(WC()->cart->get_total('edit')));
$context['cart_items'] = [];
$context['content_ids'] = [];
@ -337,7 +337,7 @@ add_action('wp_head', function() {
$item_data = [
'item_id' => $product->get_id(),
'item_name' => $product->get_name(),
'price' => floatval($product->get_price()),
'price' => round_price_with_tax(floatval($product->get_price())),
'quantity' => intval($cart_item['quantity']),
'category' => wp_get_post_terms($product->get_id(), 'product_cat', ['fields' => 'names'])[0] ?? '',
];
@ -364,7 +364,7 @@ add_action('wp_head', function() {
$order_items[] = [
'item_id' => $product->get_id(),
'item_name' => $product->get_name(),
'price' => floatval($item->get_total() / $item->get_quantity()),
'price' => round_price_with_tax(floatval($item->get_total() / $item->get_quantity())),
'quantity' => intval($item->get_quantity()),
'category' => wp_get_post_terms($product->get_id(), 'product_cat', ['fields' => 'names'])[0] ?? '',
];
@ -375,7 +375,7 @@ add_action('wp_head', function() {
$context['order'] = [
'id' => $order->get_id(),
'total' => floatval($order->get_total()),
'total' => round_price_with_tax(floatval($order->get_total())),
'currency' => $order->get_currency(),
'items' => $order_items,
'content_ids' => $content_ids,

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

@ -171,6 +171,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>

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