Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Payment dependable on Shipping


JuanIgnacio

Recommended Posts

I'm doing some changes to a payment module running in the latest 2 RC version.

 

What I need to do (and couldn't find it in the forums) is to make this payment module to be selectable (or even enabled/disabled) ONLY if a specific shipping method was selected in the previous step.

 

I'm not asking somebody to code everything for me, I'm and intermediate PHP programmer, all I need is to know how to detect which shipping method was selected and how to "turn the payment option off"

 

Is there a way to do this? If this was answered before and I missed it, please point me into the right direction

 

Thanks a lot!

Link to comment
Share on other sites

possible to do, simply modify the checkout pages code & check the session variables.

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

That's what I'm doing, modifying the pages code, but what I need to do is to find which variables to check:

$_SESSION['WHAT?'] ?

$order->what['what'] ?

 

do I have to initialize something?

 

I think $order->info['shipping_method'] should contain that, but what does that variable contain?...

 

shipping_module_file.php:

function shipping() {

$this->code = ['this variable???'];

 

 

Thanks

Edited by JuanIgnacio
Link to comment
Share on other sites

Can anyone help me with a similar code segment to display a payment method based on the shipping method selected in the previous step?

 

What I want to do is offer distinct payment on delivery modules for the 'Correos Paquete Azul' post office parcel service and Courier 'Tourline Express' delivery methods. The post office charges a fixed fee of 1.40€ to collect a cash payment on delivery while Tourline take a 5% commission with a 3.40€ minimum. So my code needs to do something like this:

 

// In psuedo code
If $shipping_method = 'tablerate' Then
 showCod2 = true;
Else If $sipping_method = 'courier' Then
 showCod1 = true;

 

Juan, did you get anywhere with that?

 

That's what I'm doing, modifying the pages code, but what I need to do is to find which variables to check:

$_SESSION['WHAT?'] ?

$order->what['what'] ?

 

do I have to initialize something?

 

I think $order->info['shipping_method'] should contain that, but what does that variable contain?...

 

shipping_module_file.php:

function shipping() {

$this->code = ['this variable???'];

 

 

Thanks

 

Many thanks :)

Link to comment
Share on other sites

Can anyone help me with a similar code segment to display a payment method based on the shipping method selected in the previous step?

 

What I want to do is offer distinct payment on delivery modules for the 'Correos Paquete Azul' post office parcel service and Courier 'Tourline Express' delivery methods. The post office charges a fixed fee of 1.40€ to collect a cash payment on delivery while Tourline take a 5% commission with a 3.40€ minimum. So my code needs to do something like this:

 

// In psuedo code
If $shipping_method = 'tablerate' Then
 showCod2 = true;
Else If $sipping_method = 'courier' Then
 showCod1 = true;

 

Juan, did you get anywhere with that?

 

 

 

Many thanks :)

 

I'm thinking I should insert my code into calalog/includes/classes/payment.php. I'll allow all enabled payment modules to be loaded into the array normally (including both cash-on-delivery methods) then test and remove the module/s that are not relevant to the shipping method before the test for "only one payment module" is performed:

 

// if there is only one payment method, select it as default because in
// checkout_confirmation.php the $payment variable is being assigned the
// $HTTP_POST_VARS['payment'] value which will be empty (no radio button selection possible)
	if ( (tep_count_payment_modules() == 1) && (!isset($GLOBALS[$payment]) || (isset($GLOBALS[$payment]) && !is_object($GLOBALS[$payment]))) ) {
	  $payment = $include_modules[0]['class'];
	}

	if ( (tep_not_null($module)) && (in_array($module, $this->modules)) && (isset($GLOBALS[$module]->form_action_url)) ) {
	  $this->form_action_url = $GLOBALS[$module]->form_action_url;
	}

Link to comment
Share on other sites

Pete:

 

Most shipping and payment methods have a way to add a fee just for using them. You don't have to detect the method used, just make the method to add this fee and it will only be added if the method is selected. Look into some module that has this fee and look for the code on how to add it to the total.

Link to comment
Share on other sites

I'm detecting the shipping method this way:

 

if (substr_count($order->info['shipping_method'], '>>Shipping Name<<') > 0) {

.... }

 

I'm done with that. The thing is I CAN'T TURN THE PAYMENT METHOD OFF. I placed "$this->enabled == false; " and "$check_flag = false;" inside the if, outside the if, in the before_process() function.... and the payment method it's still there for the user to select.

 

How in the world do I disable the payment method after detecting the shipping method selected??

Link to comment
Share on other sites

Pete:

 

Most shipping and payment methods have a way to add a fee just for using them. You don't have to detect the method used, just make the method to add this fee and it will only be added if the method is selected. Look into some module that has this fee and look for the code on how to add it to the total.

 

That's great, but I want my customers to still have the choice of using another payment method after selecting their preferred shipping method. And I don't want to charge everyone a handling fee to cover payment on delivery even if they are paying by PayPal. That would be unfair and artificially inflate the cost of shipping, which is already quite high and causing some customers to abandon the checkout process at the shipping page.

 

Have you tried removing the payment method completely from the array $payment ?

Link to comment
Share on other sites

Pete

 

If I understand, what your trying to do is to charge for the Contrareembolso service if that's how they pay for. The best way to do this, I think, is to create a OrderTotal (totalización) module. Do a simple check to detect which payment method was selected and make the OrderTotal module to create a CARGO POR CONTRAREEMBOLSO fee. I think that should be fine and pretty easy.

 

Have you tried removing the payment method completely from the array $payment ?

 

Mmmm... no, how can I do that?

Link to comment
Share on other sites

  • 3 weeks later...
That looks like a nice contrib if it does what it says. Unfortunately the download links seem to be broken, I'll try again later.

I installed the Cash on Delivery Fee contrib and its working great for my table rate shipping module, but I have a courier module that's not in the list. Is codfee supported on the forum? How do you add a shipping method to codfee?

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...