Jump to content

Recommended Posts

Hi

I'm trying to modify a Shipping module for an online shop but I'm not getting it to work...I want to put two options on that, if customer chooses first option he gets one price for the shipment if he chooses second option then he gets a different price.

 

The original module only allows one option for Shipment Method and I want to add a second option using two radio buttons.

 

Basically I want to check what radio button is selected and then get the value, if first radio button is checked get it's value if the second radio button is checked get the previous value plus and aditional tax.

Here goes the code:

 

 $_SESSION[$value] = "1";
      $string = " <input type=\"radio\"  id=\"radio1\" name=\"shipping_rate_id\" value=\"$value\" />";
      $string .= "  Zone Shipping -  $country_name <strong><div class='zone'>". $CURRENCY_DISPLAY->getFullValue($rate )."</div></strong>";
      $string .= "<br /> <input type=\"radio\"  id=\"radio2\"name=\"shipping_rate_id\" value=\"$value\" />";
      $string .= "  Contra Re-embolso (+ 1.50€)<strong><div class='zone'>". $CURRENCY_DISPLAY->getFullValue($rate+1.50 )."</div></strong>";
      echo $string;
    }

  function get_rate( &$d ) {	
      
  if (document.getElementById("radio2").checked) {
      $shipping_rate_id = vmGet($_REQUEST,"shipping_rate_id")+1.50;
  $zone_arr = explode("|", urldecode(urldecode($shipping_rate_id)) );
  $order_shipping = $zone_arr[3];
      } else {
  $shipping_rate_id = vmGet($_REQUEST,"shipping_rate_id");
  $zone_arr = explode("|", urldecode(urldecode($shipping_rate_id)) );
  $order_shipping = $zone_arr[3];
   }
  
  return $order_shipping;
  }

Link to comment
https://forums.phpfreaks.com/topic/222413-php-radio-button-condition/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.