News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Klarna Checkout - Unclear partly error message about tax in cart

Started by Rune Rasmussen, March 16, 2015, 13:41:31 PM

Previous topic - Next topic

Rune Rasmussen

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?
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

Rune Rasmussen

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;
        }
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

Rune Rasmussen

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...
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

GJC Web Design

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?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Rune Rasmussen

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...
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Rune Rasmussen

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.
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Rune Rasmussen

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. :)
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

Rune Rasmussen

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 ';
Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Rune Rasmussen

Rune Rasmussen - https://www.syntaxerror.no/

Norwegian Translation Team