# آموزش سفارشی سازی صفحه تشکر از خرید ووکامرس

- پیوند: https://negarnovin.com/custom-tracking-code-for-the-thanks-page/
- منتشرشده: 2025-09-23T14:56:54+00:00
- نویسنده: نگارنوین

# کد رهگیری سفارشی برای صفحه تشکر

**محدوده پشتیبانی :**

ما نمی توانیم طبق **سیاست پشتیبانی** خود، پشتیبانی برای سفارشی سازی ها ارائه دهیم.
اگر نیاز به سفارشی سازی یک قطعه کد یا گسترش قابلیت های آن دارید، توصیه می کنیم با
یک شریک آژانس Woo یا یک توسعه دهنده WooCommerce در Codeable همکاری کنید .** **

این قطعه کد برای اضافه کردن قابلیت ردیابی برای یک نرم افزار تحلیلی جداگانه است که
ممکن است [نصب](https://negarnovin.com/unlimited-traffic-virtual-server/) کرده باشید.
شیء سفارش شامل تمام داده های سفارش مورد نیاز شما، از جمله ردیف های سفارش، است.

[**سرور مجازی انگلیس**](https://negarnovin.com/%d8%b3%d8%b1%d9%88%d8%b1-%d9%85%d8%ac%d8%a7%d8%b2%db%8c-%d8%a7%d9%86%da%af%d9%84%db%8c%d8%b3/)

شما باید این کد را به `functions.php`فایل قالب فرزند خود یا از طریق افزونه ای که
امکان اضافه کردن توابع سفارشی را فراهم می کند، مانند افزونه [Code snippets،](https://translate.google.com/website?sl=en&tl=fa&hl=en&client=webapp&u=https://wordpress.org/plugins/code-snippets/)
اضافه کنید . لطفاً کد سفارشی را مستقیماً به فایل قالب والد خود اضافه نکنید `functions.
php`زیرا هنگام به روزرسانی قالب، این کد به طور کامل پاک می شود.

  |  /** |  
 |  * Add custom tracking code to the thank-you page |  
 |  */ |  
 |  add_action( ‘woocommerce_thankyou’, ‘my_custom_tracking’ ); |  
 |   |  
 |  function my_custom_tracking( $order_id ) { |  
 |   |  
 |  // Lets grab the order |  
 |  $order = wc_get_order( $order_id ); |  
 |   |  
 |  /** |  
 |  * Put your tracking code here |  
 |  * You can get the order total etc e.g. $order->get_total(); |  
 |  */ |  
 |   |  
 |  // This is the order total |  
 |  $order->get_total(); |  
 |   |  
 |  // This is how to grab line items from the order |  
 |  $line_items = $order->get_items(); |  
 |   |  
 |  // This loops over line items |  
 |  foreach ( $line_items as $item ) { |  
 |  // This will be a product |  
 |  $product = $order->get_product_from_item( $item ); |  
 |   |  
 |  // This is the products SKU |  
 |  $sku = $product->get_sku(); |  
 |   |  
 |  // This is the qty purchased |  
 |  $qty = $item[‘qty’]; |  
 |   |  
 |  // Line item total cost including taxes and rounded |  
 |  $total = $order->get_line_total( $item, true, true ); |  
 |   |  
 |  // Line item subtotal (before discounts) |  
 |  $subtotal = $order->get_line_subtotal( $item, true, true ); |  
 |  } |  
 |  } |

wc-custom-tracking-code-for-thanks-page.php طراحی شده ⌊❤⌉ توسط نگارنوین

### 📌 خلاصه

آموزش سفارشی سازی صفحه تشکر از خرید فروشگاه ووکامرس وردپرس Custom tracking code 
for the thanks page کد رهگیری سفارشی برای صفحه تشکر

## 🔗 مطالب مرتبط

 * [خرید سرور مجازی تحویل آنی](https://negarnovin.com/%d8%ae%d8%b1%db%8c%d8%af-%d8%b3%d8%b1%d9%88%d8%b1-%d9%85%d8%ac%d8%a7%d8%b2%db%8c-%d8%aa%d8%ad%d9%88%db%8c%d9%84-%d8%a2%d9%86%db%8c/)
 * [خرید سرور مجازی برای ماینینگ](https://negarnovin.com/%d8%ae%d8%b1%db%8c%d8%af-%d8%b3%d8%b1%d9%88%d8%b1-%d9%85%d8%ac%d8%a7%d8%b2%db%8c-%d8%a8%d8%b1%d8%a7%db%8c-%d9%85%d8%a7%db%8c%d9%86%db%8c%d9%86%da%af/)
