I have tried deactivating the option "auto submit shipping and payment methods selection" in the HikaShop configuration but that does not solve the problem
I understand your way of keeping totals and shipping-methods updated on screen by submitting all changes to address or shipping method to the server and that the server-side submit-handler requires that all shipping methods and their prices exists in the database.
Support for dynamic price has been added to template checkout/shipping.php (line 4-8 in code below):
if($this->config->get('auto_submit_methods',1) && empty($checked))
$checked.=' onclick="this.form.action=this.form.action+\'#hikashop_shipping_methods\';this.form.submit(); return false;"';
if (isset($_REQUEST['shipping_price'])) {
$rate->shipping_price = $_REQUEST['shipping_price'];
$rate->shipping_price_with_tax = floatval($_REQUEST['shipping_price']) * (1 + $rate->taxes[0]->tax_rate);
$rate->taxes[0]->tax_amount = $rate->shipping_price_with_tax - $rate->shipping_price;
}
if(empty($rate->shipping_price_with_tax))
$rate->shipping_price_with_tax = $rate->shipping_price;
ps! The code above may fail because the object $rate->taxes does not exist if the requested shipping-method has no price
Support for calculation and display of total cart-weight has been implemented in template checkout / cart.php
As mentioned previously I have removed all default submitters on everything except the Finish-button because I'm loading the shipping methods by javascript from an external shipping-agent (Bring).
The agent requires at least 2 parameters, the postalcode and the weight of the shipment and accepts a list of products to check and return. The returned answer do not contain requested products that has a weight limit below the requested weight.
The price on returned products depends on the weight
My client-side implementation is done by:
- onload-handler loads the external shipping methods by ajax using postalcode and weight picked up from screen
- ajax onload-handler displays the shipping methods and triggers click on default shipping method which add or set a hidden input (shipping_price)
- All screen objects that are changing shipping_address or shipping_price calls a function that recalculates and displays new totals
To me it seems like everything works as it should except the fact that my final submit triggered by the Finish-button gets trapped by your serverside submithandler and flagged as invalid because the shipping method sent from the server do not match the shipping-method submitted
In order to make it work I need to disable that check if isset($_REQUEST['shipping_price'])
- In which file and line is the check?
I guess I'm not the only one that has the need for dynamically loaded shipping methods with dynamic prices so it would be nice if you implemented my or another solution to handle this situation