vyskoczilova / woocommerce-payforpayment

WordPress plugin WooCommerce Pay for Payment
13 stars 10 forks source link

Cannot change tax class in dropdown #73

Open musilondrej opened 1 year ago

musilondrej commented 1 year ago

Hello, I have encountered an issue where selecting any tax class from the dropdown menu proves to be non-functional. When attempting to change the tax class to "standard," the settings do not update and instead revert to the default value of "Payment fee tax class based on cart items."

Steps to Reproduce:

  1. I go to the COD payment settings where the tax class selection dropdown is presented.
  2. I try to change the tax class to "standard" or any other available option.
  3. I click "Save" to apply the changes.
  4. I observe that the tax class setting does not update and reverts to the default "Payment fee tax class based on cart items" after the page refreshes or when I navigate away from the settings page.

Environment:

Thank you for your attention to this matter.

musilondrej commented 1 year ago

Upon further investigation, I suspect that the issue may be related to a specific segment of the code. I have identified a potential problem in the method that sanitizes the tax class input:

private function _sanitize_tax_class( $tax_option, $default = 'incl' ) {
    if ( in_array( $tax_option, array( 0, 'incl', 'excl' ) ) )
        return $tax_option;
    return $default;
}

It appears that this method is designed to return the $tax_option if it matches one of the specified values (0, 'incl', 'excl'). However, it does not account for other valid tax class options that might be passed to it. As a result, any value other than the ones explicitly checked in the in_array function call will result in the method returning the $default value, which is 'incl'.

Thank you for looking into this.