Dear Mediafaune,
First of all, you need to be aware that the plugin calculates shipping costs based on CART characteristics. In particular, the onVmShippingRulesGetCartValues is passed the whole cart and the list of products to be considered (e.g. when there is a evaluate_for_categories(....) call, the onVmShippingRulesGetCartValues function will be called to get the cart variables for just the products that have the desired categories. The $cart will always be the full cart, though. So to get the calculations right, you really need to use the $products list rather than the $cart.
Second, each member of the $products list has an array of all customfields, so if you want to set the variable Dangerous to true (value 1), then you need to loop through all products, for each product loop through all customfields of that product and if the customfield is the "Dangerous" customfield, then check the value of the custom field. I would write the code like:
function onVmShippingRulesGetCartValues(&$cartvals, $cart, $products, $method, $cart_prices) {
$cartvals['dangerous'] = false;
foreach ($products as $p) {
foreach ($p->customfields as $cf) {
if ($cf->custom_title=="Dangerous" and $cf->customfield_value==1) {
$cartvals['dangerous'] = true;
}
}
}
}
This should give you an idea how you can adjust the code if you use other custom field values.
Best regards,
Reinhold