Post by Univest » Sun May 29, 2011 11:41 pm

Can you please give example of how you can
hide the cash on delivery option when weight based shipping is selected.
thank you version 1495



Qphoria wrote:There are easy code hacks you can add to certain shipping modules that will basically "force" the payment module.

Example:
If you want to force "COD" when someone chooses the "free shipping" shipping method you can add this to the payment file

1. EDIT: catalog/model/payment/cod.php

2. FIND:

Code: Select all

$method_data = array( 
	'id'         => 'cod',
	'title'      => $this->language->get('text_title'),
	'sort_order' => $this->config->get('cod_sort_order')
);
3. AFTER, ADD:

Code: Select all

//Q: If free shipping is selected, override all other payment modules and force this one.
if ($this->session->data['shipping_method']['id'] == 'free.free') {
	$this->session->data['payment_method'] = $method_data;
	$this->session->data['comment'] = '';
	$this->response->redirect($this->url->https('checkout/confirm'));
}

Newbie

Posts

Joined
Fri May 13, 2011 1:18 am

Post by kapapi » Wed Oct 05, 2011 4:21 am

burniesb wrote:If you want customers to not see the COD payment option if they choose any shipping option except COD... (E.g. Show the COD payment option ONLY if they choose the COD shipping option), try the following:

1. EDIT cod.php in catalog/model/payment

2. BEFORE this line $method_data = array(); add the following code:

Code: Select all

if(isset($this->session->data['shipping_method']['id']))
{
     if ($this->session->data['shipping_method']['id'] != 'cod.cod') 
     {
            $status = false;
     }
}
3. SAVE the file and upload it.
This was working perfectly with 1.4.9.6 but it's not working with 1.5.1.
Any suggestions??

Newbie

Posts

Joined
Wed Oct 05, 2011 4:15 am

Post by kaliyas » Sat Dec 17, 2011 6:38 pm

Hi Guys.. I have been trying to get this work on, but nothing.
I paste the code and change the ID of my shipping, but when i run it on the frontend, nothing happens.

Is this method working on 1.5.13?
Thanks

New member

Posts

Joined
Sat Dec 17, 2011 6:36 pm

Post by kaliyas » Sat Dec 17, 2011 9:40 pm

I found out that one of the difference from 1.4 to 1.5 is the ID tag. Version 1.5 use 'code' instead of 'ID', so basically Im replacing the script to this

Code: Select all

if(isset($this->session->data['shipping_method']['code']))
{
     if ($this->session->data['shipping_method']['code'] != 'cod.cod') 
     {
            $status = false;
     }
}
What i get is that COD is disappearing no matter what shipping method I selected previously.
Guys, can you please give ma hand on this?

New member

Posts

Joined
Sat Dec 17, 2011 6:36 pm

Post by kaliyas » Sun Dec 18, 2011 5:57 pm

Any idea guys?

New member

Posts

Joined
Sat Dec 17, 2011 6:36 pm

Post by citadeldimon » Wed Jan 04, 2012 5:11 am

kaliyas wrote:Any idea guys?
Nobody knows how to fix a method for version 1.5? ??? :-\

Newbie

Posts

Joined
Wed Jan 04, 2012 5:09 am

Post by Qphoria » Wed Jan 04, 2012 10:27 pm

citadeldimon wrote:
kaliyas wrote:Any idea guys?
Nobody knows how to fix a method for version 1.5? ??? :-\
Answered in another thread:
http://forum.opencart.com/viewtopic.php ... 34#p235734

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by citadeldimon » Wed Jan 04, 2012 11:47 pm

Qphoria wrote:
citadeldimon wrote:
kaliyas wrote:Any idea guys?
Nobody knows how to fix a method for version 1.5? ??? :-\
Answered in another thread:
http://forum.opencart.com/viewtopic.php ... 34#p235734
Thanks, it works!
But I noticed that when editing the method of shipping, method of payment does not change :-\
remember only the first chosen method.
How can I fix this?

Newbie

Posts

Joined
Wed Jan 04, 2012 5:09 am

Post by SXGuy » Tue Sep 17, 2013 3:40 am

method of payment does change if you select the correct shipping method.

You have to apply the logic to every payment method you want to use based on a certain shipping method.

For example

catalog\model\payment\cod.php

find

Code: Select all

if ($this->config->get('cod_total') > 0 && $this->config->get('cod_total') > $total) {
			$status = false;
		} elseif (!$this->config->get('cod_geo_zone_id')) {
			$status = true;
		} elseif ($query->num_rows) {
			$status = true;
		} else {
			$status = false;
		}
Add underneath

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && $this->session->data['shipping_method']['code'] != 'free.free') {
          $status = false;
      } else {
	 $status = true;
	 }
this means if Free shipping is not selected, COD = FALSE i.e doesnt show.

do this on every payment php file for which you dont want to show COD if selected.

If there are other payment methods which you only want to show for another type of shipping, you apply the same logic to those payment php files.
Last edited by SXGuy on Tue Sep 17, 2013 9:48 pm, edited 1 time in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by citadeldimon » Tue Sep 17, 2013 1:04 pm

SXGuy thank you for your answer.

Newbie

Posts

Joined
Wed Jan 04, 2012 5:09 am

Post by SXGuy » Tue Sep 17, 2013 9:40 pm

Although this method works for front end orders, its causing conflicts with admin backend manual orders.

undefined index shipping_method

So will need to look in to making it work in the admin backend also.

EDIT ok Q had the answer in another thread, so ive updated my previous post with the correct code to stop confusion.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am
Who is online

Users browsing this forum: No registered users and 6 guests