Skip to content

Commit

Permalink
Check for VAT ID exempts before applying net prices for photovoltaic …
Browse files Browse the repository at this point in the history
…systems.
  • Loading branch information
dennisnissle committed Dec 12, 2024
1 parent 1e24f43 commit c6c3eba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion includes/class-wc-gzd-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ public function maybe_adjust_photovoltaic_cart_data( $cart ) {

if ( $checkbox = wc_gzd_get_legal_checkbox( 'photovoltaic_systems' ) ) {
if ( $checkbox->is_enabled() ) {
$is_vat_exempt = WC()->customer && WC()->customer->is_vat_exempt();

if ( $this->checkbox_is_checked( $checkbox ) && wc_gzd_cart_applies_for_photovoltaic_system_vat_exemption( $cart->get_cart() ) ) {
foreach ( $cart->get_cart() as $cart_item_key => $values ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $values['data'], $values, $cart_item_key );
Expand All @@ -354,7 +356,7 @@ public function maybe_adjust_photovoltaic_cart_data( $cart ) {
$_product->set_tax_class( get_option( 'woocommerce_gzd_photovoltaic_systems_zero_tax_class', 'zero-rate' ) );
}
}
} elseif ( apply_filters( 'woocommerce_gzd_photovoltaic_systems_remove_zero_tax_class_for_non_exemptions', ( is_checkout() || $this->checkbox_is_visible( 'photovoltaic_systems' ) ) ) ) {
} elseif ( apply_filters( 'woocommerce_gzd_photovoltaic_systems_remove_zero_tax_class_for_non_exemptions', ( ! $is_vat_exempt && ( is_checkout() || $this->checkbox_is_visible( 'photovoltaic_systems' ) ) ) ) ) {
foreach ( $cart->get_cart() as $cart_item_key => $values ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $values['data'], $values, $cart_item_key );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function trigger( $order_id ) {

if ( $gateway ) {
if ( $has_removed_hook && is_callable( array( $gateway, 'email_instructions' ) ) ) {
add_action( 'woocommerce_email_before_order_table', array( $gateway, 'email_instructions' ) );
add_action( 'woocommerce_email_before_order_table', array( $gateway, 'email_instructions' ), 10, 3 );
}

do_action( 'woocommerce_gzd_maybe_add_email_payment_instructions_after_removal', $this->object );
Expand Down
3 changes: 2 additions & 1 deletion includes/wc-gzd-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1828,8 +1828,9 @@ function wc_gzd_get_photovoltaic_system_customer_location( $args = array() ) {
function wc_gzd_customer_applies_for_photovoltaic_system_vat_exemption( $args = array() ) {
$args = wc_gzd_get_photovoltaic_system_customer_location( $args );
$applies_for_photovoltaic_vat_exemption = false;
$is_vat_exempt = WC()->customer && WC()->customer->is_vat_exempt();

if ( empty( $args['company'] ) || apply_filters( 'woocommerce_gzd_allow_b2b_photovoltaic_system_vat_exemption', false ) ) {
if ( ! $is_vat_exempt && ( empty( $args['company'] ) || apply_filters( 'woocommerce_gzd_allow_b2b_photovoltaic_system_vat_exemption', false ) ) ) {
/**
* Allow VAT exemption for:
* - shipments to a country supporting photovoltaic exempts (from the base country or from another EU country which takes part in OSS procedure).
Expand Down
10 changes: 5 additions & 5 deletions woocommerce-germanized.php
Original file line number Diff line number Diff line change
Expand Up @@ -1568,11 +1568,11 @@ public function add_gtin_fallback( $gtin, $product ) {

public function add_structured_product_data( $markup, $product ) {
if ( $gzd_product = wc_gzd_get_gzd_product( $product ) ) {
if ( ! isset( $markup['gtin'] ) || empty( $markup['gtin'] ) ) {
if ( $gtin = $gzd_product->get_gtin() ) {
$markup['gtin'] = $gtin;
}
}
if ( ! isset( $markup['gtin'] ) || empty( $markup['gtin'] ) ) {
if ( $gtin = $gzd_product->get_gtin() ) {
$markup['gtin'] = $gtin;
}
}

if ( ! isset( $markup['mpn'] ) || empty( $markup['mpn'] ) ) {
if ( $mpn = $gzd_product->get_mpn() ) {
Expand Down

0 comments on commit c6c3eba

Please sign in to comment.