voided Posted December 11, 2008 Share Posted December 11, 2008 I'm having some problems with the Javascript (hopefully its only the JS) for the shipping method radio buttons whit B2BSuite. the buttons are checked only on the first load of checkout_shipping.php because theres a function to automatically select the cheapest method. if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest(); But if you click back or go trough the shopping cart again none of the shipping radio button (i havent tested with the payment yet as i only have 1 payment method anyways) will be selected. Thankfully theres a warning that pops up if you try to continue without reselecting a shipping method... i pinpointed the problem here (checkout_shipping.php): // one button is not an array if (document.checkout_payment.shipping[0]) { document.checkout_payment.shipping[buttonSelect].checked=true; } else { document.checkout_payment.shipping.checked=true; } document.checkout_payment.shipping[0] is wrong as it should be document.checkout_payment.shipping_<? echo $vendor_id; ?>[0] or something like that... Anyone got an idea how to fix this? or even better a working version of that javascript block for b2bsuite? quick edit: this comes from the MVS (multiple vendor shipping) code. which is used by b2bsuite i guess. Designrfix.com | Graphic Design Inspiration & Web Design Resources - @designrfix Link to comment Share on other sites More sharing options...
voided Posted December 11, 2008 Author Share Posted December 11, 2008 actually this javascript thing is simply for the color bar on hover effect... nothing to do with selecting the shipping method i think :( Designrfix.com | Graphic Design Inspiration & Web Design Resources - @designrfix Link to comment Share on other sites More sharing options...
voided Posted December 11, 2008 Author Share Posted December 11, 2008 well i managed to fix this mess of radio buttons (javascript) but they still dont "stick" ie. they reset when you continue and go back to checkout_shipping (either by going back to the shopping cart or clicking the step bar at the bottom of the checout pages) find in includes/modules/vendor_shipping.php <?php } else { for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) { // set the radio button to be checked if it is the method chosen $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false); if ( ($checked == true) || ($n == 1 && $n2 == 1) ) { echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } else { echo ' <tr class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n"; } ?> replace with: <?php } else { for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) { // set the radio button to be checked if it is the method chosen $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false); if ( ($checked == true) || ($n == 1 && $n2 == 1) ) { echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect'.$vendor_id.'(this)" onmouseout="rowOutEffect'.$vendor_id.'(this)" onclick="selectRowEffect'.$vendor_id.'(this, ' . $radio_buttons . ')">' . "\n"; } else { echo ' <tr class="moduleRow" onmouseover="rowOverEffect'.$vendor_id.'(this)" onmouseout="rowOutEffect'.$vendor_id.'(this)" onclick="selectRowEffect'.$vendor_id.'(this, ' . $radio_buttons . ')">' . "\n"; } ?> and in checkout_shipping.php find: <script language="javascript"><!-- var selected; function selectRowEffect2(object, buttonSelect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected2'; selected = object; // one button is not an array if (document.checkout_payment.shipping[0]) { document.checkout_payment.shipping[buttonSelect].checked=true; } else { document.checkout_payment.shipping.checked=true; } } function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } //--></script> and replace with this: <script language="javascript"><!-- var selected; <? $vendor_shipping = $cart->vendor_shipping(); foreach ($vendor_shipping as $vendor_id => $vendor_data) { ?> function selectRowEffect<? echo $vendor_id; ?>(object, buttonSelect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_payment.shipping_<? echo $vendor_id; ?>[0]) { document.checkout_payment.shipping_<? echo $vendor_id; ?>[buttonSelect].checked=true; } else { document.checkout_payment.shipping_<? echo $vendor_id; ?>.checked=true; } } function rowOverEffect<? echo $vendor_id; ?>(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect<? echo $vendor_id; ?>(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } <? } ?> //--></script> Designrfix.com | Graphic Design Inspiration & Web Design Resources - @designrfix Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.