Post by kaliyas » Tue Dec 20, 2011 3:21 am

Hi guys how are you? I have two payment options (COD and Bank Transfer) and I have several shipping (A, B, C). I want to be a able to disable COD if customer selects "A" or "B" Shipping option.

I found this code and try to get it work on 1.5.13 without result.

Code: Select all

if(isset($this->session->data['shipping_method']['code']))
{
     if ($this->session->data['shipping_method']['code'] != 'cod.cod') 
     {
            $status = false;
     }
}
Can you give me hand?

New member

Posts

Joined
Sat Dec 17, 2011 6:36 pm

Post by tschiff » Tue Jan 03, 2012 9:19 am

an answer would be super nice...

Newbie

Posts

Joined
Wed Nov 23, 2011 2:36 am

Post by Qphoria » Tue Jan 03, 2012 10:57 pm

well for starters:

if ($this->session->data['shipping_method']['code'] != 'cod.cod')

is not valid since cod is a payment method. Unless you have a custom cod shipping method.. that is unclear from the post.

But you can do this for each payment you want to alter.

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

2. FIND:

Code: Select all

if ($status) {
3. BEFORE, ADD:

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && $this->session->data['shipping_method']['code'] == 'flat.flat') {
    $status = false;
}

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ronwong » Fri Jan 06, 2012 11:06 pm

Dont seem to work, I just tried it on COD on latest 1.5.1.3

I want to disable COD if item ship by post (weight) because I cannot mail the thing and go and collect cash.

I included the code in the cod.php file:

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && $this->session->data['shipping_method']['code'] == 'weight.weight') {
    $status = false;
}

Newbie

Posts

Joined
Fri Jan 06, 2012 10:17 am

Post by Qphoria » Fri Jan 06, 2012 11:40 pm

Code isn't weight.weight for weight as it has multiple rates
try just "weight" or maybe

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && strpos($this->session->data['shipping_method']['code'], 'weight') !== false) {
    $status = false;
}

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Johnathan » Sat Jan 07, 2012 1:23 am

I've now released a Restrict Payment Methods extension that allows you to limit the availability of payment methods based on the shipping method selected.

It also can restrict based on customer group, currency, cart quantity/sub-total/volume/weight/date, category, manufacturer, or product.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by ronwong » Sat Jan 07, 2012 9:15 am

Jonathan, I appreciate your offer, I have seen the paid addons, they must be good but I had spent a bit too much for the time for open source platform.

Qphoria, I took your code and it works, I am no programmer so just see and derive, and there is an issue the way the page loads, for example, when the "weight" method is choosen, next, COD is hidden, perfect, but then it is "locked", so if the customer decide to change his mind and scrolls back to change to self collect now, it wont reappear, or if they decide original for deivery, COD available, the go back and change to weight shipping, and COD is still there, they have to go through the whole "session" of checkout without changing their mind for it to work.

Newbie

Posts

Joined
Fri Jan 06, 2012 10:17 am

Post by jim_vam » Thu Jan 12, 2012 7:07 pm

ronwong wrote:Jonathan, I appreciate your offer, I have seen the paid addons, they must be good but I had spent a bit too much for the time for open source platform.

Qphoria, I took your code and it works, I am no programmer so just see and derive, and there is an issue the way the page loads, for example, when the "weight" method is choosen, next, COD is hidden, perfect, but then it is "locked", so if the customer decide to change his mind and scrolls back to change to self collect now, it wont reappear, or if they decide original for deivery, COD available, the go back and change to weight shipping, and COD is still there, they have to go through the whole "session" of checkout without changing their mind for it to work.
+1 for me also looking for the same thing. That is to restrict payment option depending on shipping option.

http://www.pcplace.gr
Opencart with X3D HTML5 WebGl 3D objects


User avatar
New member

Posts

Joined
Wed Dec 07, 2011 6:40 am

Post by straightlight » Sat Jan 14, 2012 7:49 am

A simple line of editing from the checkout payment core with VQMod should suffice to apply these type of modifications. Also, building a contribution for such subject could be endless while this if statement could also grow larger at anytime from the XML.

Attachments

Disable payment option based on shipping option - v1.5.1.3 .


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by pdm » Wed Jan 18, 2012 2:06 am

ronwong wrote:Qphoria, I took your code and it works, I am no programmer so just see and derive, and there is an issue the way the page loads, for example, when the "weight" method is choosen, next, COD is hidden, perfect, but then it is "locked", so if the customer decide to change his mind and scrolls back to change to self collect now, it wont reappear, or if they decide original for deivery, COD available, the go back and change to weight shipping, and COD is still there, they have to go through the whole "session" of checkout without changing their mind for it to work.
Hi quys,
This method works, but you have to do a small change, try this:

1. Edit catalog/controller/checkout/shipping.php

FIND:

Code: Select all

if (!$json) {
				$shipping = explode('.', $this->request->post['shipping_method']);
AND REPLACE:

Code: Select all

if (!$json) {		
				unset($this->session->data['payment_methods']);
				unset($this->session->data['payment_method']); 
				$shipping = explode('.', $this->request->post['shipping_method']);
For me works, even if the customer changes their mind and change the delivery method.

pdm
Newbie

Posts

Joined
Wed Jan 18, 2012 1:33 am

Post by eline » Wed Mar 07, 2012 1:52 am

Hello
I have problem with 1.5.1.3 payments, to enable COD when weight_5 is selected. I dont supply goods outside country with COD, so I have to find a method to disable COD for all other zones - just not zone weight_5. Shipping method is only one - depend on weight. Any clue?

Polskie forum OpenCart: http://forum.opencart.com/viewforum.php?f=164


New member

Posts

Joined
Tue Oct 06, 2009 10:52 pm

Post by zoltrix » Thu Jul 12, 2012 7:16 pm

The code(Qphoria) worked for me on 1.5.3.1:
before
if ($status) {
on /catalog/model/payment/cod.php

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && $this->session->data['shipping_method']['code'] == 'free.free') {
    		$status = false;
		}
My example:
Over 50 Euros free shipping selected hide on step 5 the module COD and only showing PAYPAL and bank transfer.

Newbie

Posts

Joined
Fri Oct 07, 2011 12:20 am

Post by allen551210 » Tue Jul 17, 2012 3:35 pm

Hi guys how are you?

How to change the comment to required field ?

If comments is empty, to alert a warring.

Newbie

Posts

Joined
Sun May 06, 2012 2:14 am

Post by straightlight » Wed Jul 18, 2012 2:37 am

In catalog/controller/checkout/shipping_method.php file,

find:

Code: Select all

if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {			
					$json['error']['warning'] = $this->language->get('error_shipping');
				}
add after:

Code: Select all

if (empty($this->request->post['comment'])) {
    $json['error']['warning'] = $this->language->get('error_comment');
}
In catalog/language/english/checkout/checkout.php file,

find:

Code: Select all

$_['error_shipping']
add below:

Code: Select all

$_['error_comment'] = 'Please fill out the comment box.';
This should do it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by ShopOholic » Tue Aug 14, 2012 6:23 pm

pdm wrote:
ronwong wrote:Qphoria, I took your code and it works, I am no programmer so just see and derive, and there is an issue the way the page loads, for example, when the "weight" method is choosen, next, COD is hidden, perfect, but then it is "locked", so if the customer decide to change his mind and scrolls back to change to self collect now, it wont reappear, or if they decide original for deivery, COD available, the go back and change to weight shipping, and COD is still there, they have to go through the whole "session" of checkout without changing their mind for it to work.
Hi quys,
This method works, but you have to do a small change, try this:

1. Edit catalog/controller/checkout/shipping.php

FIND:

Code: Select all

if (!$json) {
				$shipping = explode('.', $this->request->post['shipping_method']);
AND REPLACE:

Code: Select all

if (!$json) {		
				unset($this->session->data['payment_methods']);
				unset($this->session->data['payment_method']); 
				$shipping = explode('.', $this->request->post['shipping_method']);
For me works, even if the customer changes their mind and change the delivery method.

I've tried this, but it doesn't seem to work. It wont change back if the customer changes their mind. Anyone have a solution?

New member

Posts

Joined
Sat Jan 07, 2012 9:06 pm

Post by SelfMan » Thu Oct 11, 2012 11:10 pm

Works for me very nicely. Both modification have to be applied as described above to get it working properly. (cod.php and shipping.php)

New member

Posts

Joined
Thu Dec 01, 2011 8:01 am

Post by bluebeard » Fri Oct 12, 2012 6:54 pm

Qphoria wrote:Code isn't weight.weight for weight as it has multiple rates
try just "weight" or maybe

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && strpos($this->session->data['shipping_method']['code'], 'weight') !== false) {
    $status = false;
}
This worked for me. I wanted COD to be disabled if weight-based shipping had been selected ;)

Newbie

Posts

Joined
Wed Oct 10, 2012 2:40 pm

Post by tolinho » Sat Oct 13, 2012 12:26 am

Qphoria wrote:1. EDIT: catalog/model/payment/somepay.php

2. FIND:

Code: Select all

if ($status) {
3. BEFORE, ADD:

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && $this->session->data['shipping_method']['code'] == 'flat.flat') {
    $status = false;
}
Thanks :)
Works perfectly in 1.5.4.1.

New member

Posts

Joined
Sat Jul 21, 2012 2:01 am

Post by bluebeard » Sun Oct 14, 2012 8:38 pm

bluebeard wrote:
Qphoria wrote:Code isn't weight.weight for weight as it has multiple rates
try just "weight" or maybe

Code: Select all

if (isset($this->session->data['shipping_method']['code']) && strpos($this->session->data['shipping_method']['code'], 'weight') !== false) {
    $status = false;
}
This worked for me. I wanted COD to be disabled if weight-based shipping had been selected ;)
Hi again! While the above worked like a charm, i have another question - i want Paypal standard to be disabled when Pickup From Store is selected, leaving COD as the only payment option.

So applying in the same logic that Qphoria taught us here, in my pickup.php i inserted the following above

Code: Select all

$status = false;

Code: Select all

		if (isset($this->session->data['payment_method']['code']) && strpos($this->session->data['payment_method']['code'], 'pp_standard') !== false) {
And uh.. unsurprisingly it doesn't work, since i am not much of an OC expert :clown:

Any help would be much appreciated. Thank you!

Newbie

Posts

Joined
Wed Oct 10, 2012 2:40 pm

Post by rdvapors » Sun Aug 11, 2013 1:10 am

Would it be possible to restrict payment and shipping on coupon code?

Example
Coupon Code = FREE
Conditions of Coupon Code:
Fixed amount = $x.xx

customer enters coupon code,
payment and shipping are disabled

also
if customer adds another item payment payment and shipping becomes active and coupon code fixed amount remains active.

also
if customer adds enough items to satisfy free shipping amount, coupon code remains active at fixed amount and shipping is disabled.

also
only this coupon code will work.

Visual example

Cart amount:
$5.98
Coupon Code FREE entered,
Coupon Code FREE Applied -$5.98
Cart total = $0.00
Shipping = Free
checkout success.

CONDITION 2
Cart amount:
$15.98
Coupon Code Free entered,
Coupon Code FREE Applied -$5.98
Cart total =$10.00
Shipping = "Whatever shipping"
Shipping selected,
Payment info entered,
checkout success.

CONDITION 3
Cart amount:
$50.00
Coupon Code FREE entered,
Coupon Code FREE applied -$5.98
Cart total =$44.02 "Free Shipping Triggered"
Payment info entered,
checkout success.

New member

Posts

Joined
Thu Dec 13, 2012 11:29 pm
Who is online

Users browsing this forum: No registered users and 42 guests