VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: Rune Rasmussen on March 16, 2015, 13:41:31 PM

Title: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 16, 2015, 13:41:31 PM
QuoteError  vmError: KlarnaCheckout getTaxShipment: expecting math operation to be +% but is 
...but is - what do the cart think it is, it doesn't tell?
Anyhow, surely it is set to be +% so this seems to be a double bug?
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 17, 2015, 11:02:04 AM
The file and function: http://dev.virtuemart.net/projects/virtuemart/repository/entry/trunk/virtuemart/plugins/vmpayment/klarnacheckout/klarnacheckout.php#L247


        function getTaxShipment($shipment_calc_id) {
                // TO DO add shipmentTaxRate in the cart
                // assuming there is only one rule +%
                $db = JFactory::getDBO();
                $q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $shipment_calc_id . '" ';
                $db->setQuery($q);
                $taxrule = $db->loadObject();
                if ($taxrule->calc_value_mathop != "+%") {
                        VmError('KlarnaCheckout getTaxShipment: expecting math operation to be +% but is ' . $taxrule->calc_value_mathop);
                }
                return $taxrule->calc_value * 100;
        }
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 17, 2015, 22:17:12 PM
Btw! Have seen this on several sites during the last year or so, as a customer/visitor, and now also at a clients site. So it seems quite common...
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: GJC Web Design on March 17, 2015, 23:25:45 PM
I have never used klarna but it appears the query  SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`="' . $shipment_calc_id . '"
is returning nothing - is a shipping tax rule set?
have you checked in the db table #__virtuemart_calcs or echo'd out what the $shipment_calc_id is?
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 18, 2015, 00:43:15 AM
Sure
Quote from: rued on March 16, 2015, 13:41:31 PM
...surely it is set to be +% so...

Seems like $shipment_calc_id isn't defined anywhere in the system, wonder if it should be $cart->cartPrices['shipment_calc_id'] instead...
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: GJC Web Design on March 18, 2015, 00:54:58 AM
it is called by

$items[$i]['tax_rate'] = $this->getTaxShipment($cart->cartPrices['shipment_calc_id']);
         $this->debugLog($cart->cartPrices['salesPriceShipment'], 'getCartItems Shipment', 'debug');

it is also written to the debug log - switch on debugging and see if it is set

but I guess if no tax rate is chosen for the shipment it will be empty.. or 0
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 18, 2015, 01:34:04 AM
OK, but please don't guess... It's set to a +% rule, as stated twice before. ;)

Anyhow it shouldn't throw an error even when shipping modules are set to 'Apply default rules' or 'Apply no rule', some needs to use those too.

'echo $shipment_calc_id;' outputs 'Array' when a +% rule is chosen, '0' if 'Apply default rules' is chosen - both is surely wrong.

Some sleep needed now... good night.
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: GJC Web Design on March 18, 2015, 09:10:37 AM
I can only guess because you don't supply any feedback that I asked you for......

Quotehave you checked in the db table #__virtuemart_calcs or echo'd out what the $shipment_calc_id is?

Quoteit is also written to the debug log - switch on debugging and see if it is set
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 18, 2015, 11:58:59 AM
Well ... from the first posting and the later repeat it gives the answer by itself. And since you have stated in your first post already that you have no clue about this module, I didn't feel for writing a lot extra about this for you. You where guessing about something stated several times, thus I mentioned it, it's sett to a +% rule... but that doesn't matter. The error output is wrong and bad for the stores anyway. :)
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 22, 2015, 13:43:26 PM
The problem is that 'shipment_calc_id' isn't defined.
Filling in the correct tax id directly in the query works as a workaround.

T.ex.:
Quote$q = 'SELECT * FROM #__virtuemart_calcs WHERE `virtuemart_calc_id`=5 ';
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: GJC Web Design on March 22, 2015, 17:52:32 PM
QuoteAnd since you have stated in your first post already that you have no clue about this module, I didn't feel for writing a lot extra about this for you.

Nice attitude...  will remember when you next ask for help   :) - and you didn't answer..

I asked what was the value of  $cart->cartPrices['salesPriceShipment'] in the plugin at that point of the code actually echo'd out - not what you had set it in the admin - std troubleshooting
Title: Re: Klarna Checkout - Unclear partly error message about tax in cart
Post by: Rune Rasmussen on March 22, 2015, 19:31:21 PM
Quote from: Rune Rasmussen on March 16, 2015, 13:41:31 PM
surely it is set to be +%
Quote from: GJC Web Design on March 17, 2015, 23:25:45 PM
is a shipping tax rule set?
Quote from: GJC Web Design on March 18, 2015, 00:54:58 AM
but I guess if no tax rate is chosen for the shipment it will be empty.. or 0
Just stop it...