• Resolved vaughnthesheep

    (@vaughnthesheep)


    Hi there,

    I recently updated your plugin on some client sites.

    I had created a custom fix to calculate the discount prior to taxes, calculate taxes after the applied discount, and display them in the respective order.

    After updating, the discount is applied before taxes, but the taxes are being applied separately, without the discount taking effect on the taxed value.

    The old code I was using no longer works with WooCommerce and I can’t use the plugin as-is without proper tax calculation. Is there an easy way to fix this?

    Screen shot for example:

    Screenshot

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Claudio Sanches

    (@claudiosanches)

    I’m trying to fix it, but no luck.

    Thread Starter vaughnthesheep

    (@vaughnthesheep)

    I found a workaround fix using your code but applying a custom coupon instead. It’s not ideal but it works. Here’s the add_discount modification if you’re interested at all:

    /**
    * Add discount.
    *
    * @param WC_Cart $cart
    */
    public function add_discount( $cart ) {
    if ( is_admin() && ! defined( ‘DOING_AJAX’ ) || is_cart() ) {
    return;
    }

    global $woocommerce;

    // Gets the settings.
    $gateways = get_option( ‘woocommerce_payment_discounts’ );

    if ( isset( $gateways[ $woocommerce->session->chosen_payment_method ] ) ) {
    // Gets the gateway discount.
    $value = $gateways[ $woocommerce->session->chosen_payment_method ];

    if ( apply_filters( ‘wc_payment_discounts_apply_discount’, 0 < $value, $cart ) ) {
    // Gets the gateway data.
    $payment_gateways = $woocommerce->payment_gateways->payment_gateways();
    $gateway = $payment_gateways[ $woocommerce->session->chosen_payment_method ];

    // Generate the discount amount and title.
    $this->cart_discount = $this->calculate_discount( $value, $cart->cart_contents_total );
    $this->discount_name = $this->discount_name( $value, $gateway );

    // Apply the discount.
    //$cart->cart_contents_total = $cart->cart_contents_total – $this->cart_discount;
    if ( !$woocommerce->cart->has_discount( ‘vc3toodwqpexeeftm5v0’ ) )
    {
    $woocommerce->cart->add_discount(‘vc3toodwqpexeeftm5v0’);
    $woocommerce->cart->calculate_totals();
    }
    }
    else
    {
    if ( $woocommerce->cart->has_discount( ‘vc3toodwqpexeeftm5v0’ ) )
    {
    $woocommerce->cart->remove_coupon(‘vc3toodwqpexeeftm5v0’);
    $woocommerce->cart->calculate_totals();
    }
    }
    }
    }

    could you try this fork:
    https://github.com/whitebox-labs/woocommerce-payment-discounts/archive/master.zip and tell if it’s working correctly now?

    Plugin Author Claudio Sanches

    (@claudiosanches)

    Fixed on version 2.2.0.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Incorrect Taxes / Display Order’ is closed to new replies.