Shipping insurance cost not added to the total in the cart.

Started by dartagnon, August 15, 2019, 09:23:02 AM

Previous topic - Next topic

dartagnon

Hello VirtueMart experts,
I've inherited a VirtueMart site, which had a few issues with old version of codes, and slowly I have got it up to date.
However there is this one critical problem that I cannot seem to find the root cause.
The site is www.karlangu.com and when you put an item in the cart, you should be able to choose a shipping method with insurance.
The site uses 'Standard Plus' shipping module, which seems no longer supported, to handle the shipping rates.
It also has insurance calculation done according to the policy (I think it is insurance cost of $25 below $1000 total or 2.5% over $1000). anyhow... the shipping options show the insurance option, but then when when I choose it, it doesn't update the cart total.
Anyone have any suggestions where I should look to troubleshoot? I don't think it generates javascript errors...
Thanks in advance.

GJC Web Design

I would assume its in this plugins implementation of the getCosts (VirtueMartCart $cart, $method, $cart_prices) function
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

dartagnon

While trying to look for the getCosts(), I've come across this snippet of code in the plugin's helper directory 'vmshipping.php', which also contains the formula for shipping insurance calculation;


                $rate_name = $row['detail']->rate_name;

                if ($cart->virtuemart_shipmentmethod_id == $methods[$rate_id]->virtuemart_shipmentmethod_id) {
                    $isinsurance = ($cart->virtuemart_insurance == 1) ? 'checked' : '';
                    $isnormal = ($cart->virtuemart_insurance != 1) ? 'checked' : '';
                } else {
                    $isinsurance = '';
                    $isnormal = '';
                }

                $html[] = '<input type="radio" name="virtuemart_shipmentmethod_id" id="shipment_id_' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '"   value="' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '" ' . $isnormal . '>' .
                '<label for="shipment_id_' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '"><span class="vmshipment">' . $carrier_name . '</span><span class="vmshipment_cost"> + ' . $show_shipping_handling . "</span></label>\n";

                $html[] = '<input type="radio" name="virtuemart_shipmentmethod_id" id="shipment_id_' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '-1"   value="' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '-1" ' . $isinsurance . '>' .
                '<label for="shipment_id_' . $methods[$rate_id]->virtuemart_shipmentmethod_id . '"><span class="vmshipment">' . $carrier_name . '</span><span class="vmshipment_cost"> + ' . $show_shiping_insurance . "</span><br /><small>Include insurance </small></label>\n";



I think this generates the radio button of the shipping methods with or without insurance.
Interesting is that the $isinsurance is always empty. That means $cart->virtuemart_insurance is never set.
Also looking at the AJAX reply, the reply simply had an error back.

It is a bit like going into a rabbit hole...

Could you help how I can find
1) how one would go about setting a value in the cart - ie. $cart->virtuemart_insurance
2) probably related to Q1 above, any pointers as to which javascript code handles the cart Ajax "https://<server>/index.php?option=com_virtuemart&view=cart"? I am guessing that the Ajax handler must be able to set the insurance flag and update total, which is not happening...

Thanks in advance.

GJC Web Design

this has to be all bespoke/hack code -- there is no such thing as $cart->virtuemart_insurance in a stock VM install
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