Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple checkbox in checkout_shipping


nathanrowe

Recommended Posts

Hi anyone / everyone,

 

Wonder if you could be of assistantance, I need to add a simple checkbox 'yes/no' to the checkout shipping file, which would then continue through the processing and finaly insert into an addition mysql tablefield in table Orders?

 

Im stuck on the sessions I cant get it to remember the value on checkout_payment.

 

Any help would be appreciated.

 

Nathan

Link to comment
Share on other sites

Hi anyone / everyone,

 

Wonder if you could be of assistantance, I need to add a simple checkbox 'yes/no' to the checkout shipping file, which would then continue through the processing and finaly insert into an addition mysql tablefield in table Orders?

 

Im stuck on the sessions I cant get it to remember the value on checkout_payment.

 

Any help would be appreciated.

 

Nathan

Can you post the code you're trying to use for creating the session value?

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Can you post the code you're trying to use for creating the session value?

 

Richard.

 

It's a bit too messy to copy into thread, I am adding info in order.php in the include folder as well as adding info to checkout_shipping, checkout_payment and checkpout process, just cant get it all to talk to each other, am i making it to complicated? Do you know of a tutorial or something to point me to, or just show me the basics of how it works?

 

P.S. many thanks for your reply.

 

Regards

 

Nathan

Link to comment
Share on other sites

It's a bit too messy to copy into thread, I am adding info in order.php in the include folder as well as adding info to checkout_shipping, checkout_payment and checkpout process, just cant get it all to talk to each other, am i making it to complicated? Do you know of a tutorial or something to point me to, or just show me the basics of how it works?

 

P.S. many thanks for your reply.

 

Regards

 

Nathan

Well, if you're storing the value in the session data, there shouldn't be any need to 'remember' it on those other pages, it will be remembered by any and all pages until the session expires... We just need to make sure you're registering it properly, and trying to call it properly...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Well, if you're storing the value in the session data, there shouldn't be any need to 'remember' it on those other pages, it will be remembered by any and all pages until the session expires... We just need to make sure you're registering it properly, and trying to call it properly...

 

Richard.

 

Hi Richard,

 

Thanks for your time!

 

I'm a little confused now, does the shipping and payment system use sessions to store the options or does the order.php store the info as it is called in all the docs?

 

Sorry for my lack of knowledge, i'm not too good with php and it's the first time i've use OSC.

 

Could you please post a simple script of a radio button or checkbox i could use in this module?

 

Basically I am just asking weather they want part order sent or if they want to wait until all of their good are in stock. then store it in the orders table for future reference.

 

I would appreciate any help you could give.

 

Regards

 

Nathan

Link to comment
Share on other sites

Hi Richard,

 

Thanks for your time!

 

I'm a little confused now, does the shipping and payment system use sessions to store the options or does the order.php store the info as it is called in all the docs?

 

Sorry for my lack of knowledge, i'm not too good with php and it's the first time i've use OSC.

 

Could you please post a simple script of a radio button or checkbox i could use in this module?

 

Basically I am just asking weather they want part order sent or if they want to wait until all of their good are in stock. then store it in the orders table for future reference.

 

I would appreciate any help you could give.

 

Regards

 

Nathan

Well, session data is used for some stuff, and not others... Mainly it's used for storage the id value of each module that's chosen by the user, such as their specific payment id value, shipping id value, etc... Then those values are used to load the class object w/ the right initializer into a regular variable instance... You should be able to do it fairly simply with something like this in checkout_shipping.php:

 

// process the selected shipping method
 if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {
if (!tep_session_is_registered('comments')) tep_session_register('comments');
if (tep_not_null($HTTP_POST_VARS['comments'])) {
  $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
}

if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
### BEGIN NEW LINE ###
if (!tep_session_is_registered('ship_partial')) tep_session_register('ship_partial');
$ship_partial = isset($HTTP_POST_VARS['ship_partial']) ? true : false;
### END NEW LINE ***

if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
  if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
	$shipping = $HTTP_POST_VARS['shipping'];

	list($module, $method) = explode('_', $shipping);
	if ( is_object($$module) || ($shipping == 'free_free') ) {
	  if ($shipping == 'free_free') {
		$quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
		$quote[0]['methods'][0]['cost'] = '0';
	  } else {
		$quote = $shipping_modules->quote($method, $module);
	  }
	  if (isset($quote['error'])) {
		tep_session_unregister('shipping');
		### BEGIN NEW LINE ###
		tep_session_unregister('ship_partial);
		### END NEW LINE ###
	  } else {
		if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
		  $shipping = array('id' => $shipping,
							'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
							'cost' => $quote[0]['methods'][0]['cost']);

		  tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
		}
	  }
	} else {
	  tep_session_unregister('shipping');
	  ### BEGIN NEW LINE ###
	  tep_session_unregister('ship_partial');
	  ### END NEW LINE ###
	}
  }
} else {
  $shipping = false;

  tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
}	
 }

Of course you'll want to change those names to whatever your field is actually called, and this will give you a $ship_partial variable in each subsequent page that will contain the value of that variable... And you can use it in a standard if check like this: if ($ship_partial) {... because a checkbox will only post its value if it's checked, otherwise that $HTTP_POST_VARS['ship_partial'] won't even exist, and will be set to false... Also, make sure you unset that value at the end of checkout_process.php where the other variables are unregistered...

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Thanks Richard,

 

Exactly what I needed, thanks for your time on time.

 

I owe you a pint!!!

 

Nathan

Mmmmmmmmm... piiiiiiint *drools like Homer* Glad to hear it's working for you :)

 

Richard.

Richard Lindsey

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...