Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PAY ON COLLECTION - osc 2.3


OSC-Sevilla

Recommended Posts

  • 3 months later...

I would like to take this one step further. . .

 

Can you make the payment option "pay on collection" only show if you have chosen "In store Pick up"

 

So, if some one chooses in store pickup, they will have regular payment options & pay on collection.

Link to comment
Share on other sites

looking at the cod.php (Cash On Delivery) payment module,

 

Line 55-60

// disable the module if the order only contains virtual products
  if ($this->enabled == true) {
    if ($order->content_type == 'virtual') {
	  $this->enabled = false;
    }
  }

 

Can I not use this same code again, yet change the if statement to say something like

if($order->shipping == 'in store pickup') {
 $this->enabled= false;
}

 

just change the if statement to use actual variables. . . what are they?

Link to comment
Share on other sites

I would like to take this one step further. . . Can you make the payment option "pay on collection" only show if you have chosen "In store Pick up" So, if some one chooses in store pickup, they will have regular payment options & pay on collection.

 

I am looking at this and rightly ther are 2 senarios:

 

1. the client selects store pickup (checkout_shipping.php) -------all payment options are viable as the client can pay for the goods and collect later, or pay on collection.

2. the client wants the goods delivered (checkout_shipping.php) ---- Now, the option to collect pay on collection should not be used.

 

just need to code in the log of the radio button for checkout_shipping.php which is stored in a variable (got to find it) and force out the pay on collection when store pickup is not chosen

Link to comment
Share on other sites

I think I found out how to do this.

 

checkout_shipping.php line 134-136

		  $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']);

 

I think all you need to do is add this code to your "In Store" payment module

// disable this module unless In Store Pickup is selected as shipping type
	  if ($this->enabled == true) {
	    if ($shipping->id == 'in_store') {
			  $this->enabled = true;
	    } else {
                 $this->enabled = false;
           }
	  }

Link to comment
Share on other sites

or better yet;

// disable this module unless In Store Pickup is selected as shipping type
			  if ($this->enabled == true) {
				if ($shipping->id !== 'in_store') {
							  $this->enabled = false;
			  }

 

The variable $shipping->id might not be 'in_store' but will be something specific to the shipping module you use for the in store pick up.

Link to comment
Share on other sites

still working on this, I have figured a bit out.

 

If you echo $shipping['id'] on checkout_payment.php you get 'spu_spu' when you choose "In Store Pickup"

 

With that, I am trying to DISABLE the payment module, cod unless the $shipping['id'] == 'spu_spu'

 

I can find where to put the conditional statement

if ($shipping['id'] !== 'spu_spu') {
$this->enabled = false;
}

Link to comment
Share on other sites

to help, edit checkout_shipping and checkout_payment.

 

add this on both pages (in red)

<h3><?php echo TABLE_HEADING_BILLING_ADDRESS; ?></h3>

<?php echo $shipping['id'];?>

 

now on checout_payment add this above (in red)

 

if ($shipping['id'] == 'flat_flat') {

echo $selection[$i]['id'];

}

 

if ( ($selection[$i]['id'] == $payment) || ($n == 1) ) {

echo ' <tr id="defaultSelected" class="moduleRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="selectRowEffect(this, ' . $radio_buttons . ')">' . "\n";

 

now you can see when going back and forth the variables

Link to comment
Share on other sites

on

cheeckout_payment

 

find:

<?php

$selection = $payment_modules->selection();

 

//if ($shipping['id'] == 'flat_flat') {

print_r($selection);

//}

 

if (sizeof($selection) > 1) {

?>

 

this will show the full array, no we muct remove the cod instance form the array if $shipping['id'] == 'flat_flat'

Link to comment
Share on other sites

OK CRACKED IT:

 

JUST DO THIS:

 

checkout_payment.php

 

FIND: $selection = $payment_modules->selection();

 

add below:

 

if ($shipping['id'] == 'flat_flat') {

unset($selection[0]);

}

 

NOTE: Make sure in admin that the payment option SORT ORDER for COD is "0" -

 

now when the user clicks for shipping they will not have the option "Payment on Collection" as they have selected to ship the product.

Link to comment
Share on other sites

OK this is work well, i ahve added other modules and found issues wqith the above now it works fine use this

 

dont use the above use this one:

 

// PAYMENT ON COLLECTION

if ($shipping['id'] !== 'spu_spu') {

unset($selection[0]);

$selection = array_values($selection);

}

Link to comment
Share on other sites

  • 1 month later...

Thanks for your work on this gfasal. I went a slightly different rout, maybe more complicated but it is working for me. The scenario goes like this.

 

I have 2 payment options, Pay now with PayPal, or expect an invoice/money request from PayPal (Pay Later)

I have 4 shipping options,

  1. out of provence (manual shipping)
  2. In province custom delivery (city shipping, no city match)
  3. In province standard delivery (city shipping, from list)
  4. In Store Pickup

What I wanted was options 1 and 2 to pay later, as shipping/delivery charges needed to be manually calculated, and options 3 & 4 have to pay via PayPal right away as charges are already calculated.

 

How did I do it? By adding a "payWhen" variable to each shipping module.

 

in desired shipping module [catalog/includes/modules/shipping] find this array/code;

$this->quotes = array('id' => $this->code,
	  'module' => MODULE_SHIPPING_PRE_DEFINED_TEXT_TITLE,
	  'methods' => array(array('id' => $this->code,
				   'title' => MODULE_SHIPPING_PRE_DEFINED_TEXT,
				   'cost' =>  MODULE_SHIPPING_PRE_DEFINED_TEXT)));

and add 'payWhen' => 'now' (or 'later') to the methods array so it looks like this

 

$this->quotes = array('id' => $this->code,
	  'module' => MODULE_SHIPPING_PRE_DEFINED_TEXT_TITLE,
	  'methods' => array(array('id' => $this->code,
                      'title' => MODULE_SHIPPING_PRE_DEFINED_TEXT,
                      'payWhen' => 'now',
				   'cost' =>  MODULE_SHIPPING_PRE_DEFINED_TEXT)));

 

This needs to be done in each shipping method to determine what payment option will be used, pay now or later.

 

Then in catalog/checkout_shipping.php find around line 135

		  $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']);

and add the 'payWhen' so it looks like this

		  $shipping = array('id' => $shipping,
							'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                               'payWhen' => $quote[0]['methods'][0]['payWhen'],
							'cost' => $quote[0]['methods'][0]['cost']);

 

Next edit catalog/checkout_payment.php around line 190 find

$selection = $payment_modules->selection();

and add after

if ($shipping['payWhen'] == 'now') {
 unset($selection[1]);
 $selection = array_values($selection);
} elseif ($shipping['payWhen'] == 'later') {
 unset($selection[0]);
 $selection = array_values($selection);
}

 

The key to removing payment modules is to know what order they are in. From the admin side, make sure you set the sort order for each payment module. That way they will sort the same each time. (any zones set will also affect this so test test test)

 

you can add the line print_r($selection); just after $selection = $payment_modules->selection(); to see the whole array.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...