Virtuemart – shipping method list – invalid markup

virtuemart-shipping-method-list

A user recently reported an odd problem on a Virtuemart site I maintain. They weren’t able to properly select the bottom two shipping methods listed (both USPS options).

I took a gander at the cart and quickly found the problem. The UPS shipping module was outputting the radio buttons wrapped in a <label> tag. Problem was, it wasn’t doing this consistently, and the last UPS shipping option had an open tag that was encompassing all the remaining radio buttons. This meant that anywhere you clicked in that region would result in the last UPS option being selected.

Now for some reason the USPS shipping module didn’t output labels at all. So I figured the most consistent solution would be to simply prevent the UPS module from outputting those <label> tags.

The method you’re looking for is ups::list_rates(), which is in the ./administrator/components/com_virtuemart/classes/shipping/ups.php file.

You can see the changes I made below on lines 362 and 384. The lines that are commented out are the original ones.

  1. $shipping_rate_id = urlencode(__CLASS__."|UPS|".$value['ServiceName']."|".$charge);
  2. $checked = (@$d["shipping_rate_id"] == $value) ? "checked=\"checked\"" : "";
  3. if (count($shipment) == 1 ) {
  4.         $checked = "checked=\"checked\"";
  5. }
  6. //$html .= '<label for="'.$shipping_rate_id.'">'."\n<input type=\"radio\" name=\"shipping_rate_id\" $checked value=\"$shipping_rate_id\" id=\"$shipping_rate_id\" />\n";
  7. $html .= "<input type=\"radio\" name=\"shipping_rate_id\" $checked value=\"$shipping_rate_id\" id=\"$shipping_rate_id\" />\n";
  8.  
  9. $_SESSION[$shipping_rate_id] = 1;
  10.  
  11. $html .= $value['ServiceName'].' ';
  12. $html .= "<strong>(".$value['TransportationCharges'].")</strong>";
  13. if (DEBUG) {
  14.         $html .= " - ".$VM_LANG->_('PHPSHOP_PRODUCT_FORM_WEIGHT').": ".$order_weight." ". $weight_measure.
  15.         ", ".$VM_LANG->_('PHPSHOP_RATE_FORM_VALUE').": [[".$charge_unrated."(".$fsc_rate.")]+".UPS_HANDLING_FEE."](".$taxrate.")]";
  16. }
  17. // DELIVERY QUOTE
  18. if (Show_Delivery_Days_Quote == 1) {
  19.         if( !empty($value['GuaranteedDaysToDelivery'])) {
  20.                 $html .= "&nbsp;&nbsp;-&nbsp;&nbsp;".$value['GuaranteedDaysToDelivery']." ".$VM_LANG->_('PHPSHOP_UPS_SHIPPING_GUARANTEED_DAYS');
  21.         }
  22. }
  23. if (Show_Delivery_ETA_Quote == 1) {
  24.         if( !empty($value['ScheduledDeliveryTime'])) {
  25.                 $html .= "&nbsp;(ETA:&nbsp;".$value['ScheduledDeliveryTime'].")";
  26.         }
  27. }
  28. if (Show_Delivery_Warning == 1 && !empty($value['RatedShipmentWarning'])) {
  29.         //$html .= "</label><br/>\n&nbsp;&nbsp;&nbsp;*&nbsp;<em>".$value['RatedShipmentWarning']."</em>\n";
  30.         $html .= "<br/>\n&nbsp;&nbsp;&nbsp;*&nbsp;<em>".$value['RatedShipmentWarning']."</em>\n";
  31. }
  32. $html .= "<br />\n";