Skip to content

Commit

Permalink
Consistently store the _additional_costs_include_tax meta during chec…
Browse files Browse the repository at this point in the history
…kout and admin order updates (for incl/excl tax scenarios).
  • Loading branch information
dennisnissle committed Oct 2, 2024
1 parent f572e66 commit 556bd7b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions includes/class-wc-gzd-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,20 +578,20 @@ public function set_cart_excluding_tax_labels( $tax_totals, $cart ) {
* @param WC_Order $order
*/
public function order_meta( $order ) {
if ( wc_gzd_additional_costs_include_tax() ) {
$order->update_meta_data( '_additional_costs_include_tax', 'yes' );
}
if ( wc_gzd_enable_additional_costs_split_tax_calculation() || wc_gzd_calculate_additional_costs_taxes_based_on_main_service() ) {
$order->update_meta_data( '_additional_costs_include_tax', wc_bool_to_string( wc_gzd_additional_costs_include_tax() ) );

if ( wc_gzd_enable_additional_costs_split_tax_calculation() ) {
$tax_shares = wc_gzd_get_cart_tax_share( 'shipping', $order->get_items() );
if ( wc_gzd_enable_additional_costs_split_tax_calculation() ) {
$tax_shares = wc_gzd_get_cart_tax_share( 'shipping', $order->get_items() );

if ( count( $tax_shares ) > 1 ) {
$order->update_meta_data( '_has_split_tax', 'yes' );
if ( count( $tax_shares ) > 1 ) {
$order->update_meta_data( '_has_split_tax', 'yes' );
}
} elseif ( wc_gzd_calculate_additional_costs_taxes_based_on_main_service() ) {
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service', 'yes' );
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service_by', wc_gzd_additional_costs_taxes_detect_main_service_by() );
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service_tax_class', wc_gzd_get_cart_main_service_tax_class() );
}
} elseif ( wc_gzd_calculate_additional_costs_taxes_based_on_main_service() ) {
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service', 'yes' );
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service_by', wc_gzd_additional_costs_taxes_detect_main_service_by() );
$order->update_meta_data( '_additional_costs_taxed_based_on_main_service_tax_class', wc_gzd_get_cart_main_service_tax_class() );
}
}

Expand Down

0 comments on commit 556bd7b

Please sign in to comment.