Zen Cart Logo
Forums / Addon Payment Modules / Do not show Nochex option if cart total over 250

Do not show Nochex option if cart total over 250

Views: 4,257

Results 1 to 20 of 48
16 Aug 2011, 10:46 AM
#1
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Do not show Nochex option if cart total over 250

Hi, I have seen a thread that shows code to add to stop one payment method if cart total exceeds a certain amount but I could not see the appropriate code in my Nochex module files.

I sell items priced from £20 to £900. I am new to Nochex and they have imposed a £250 transaction limit to start with.

What code do I need to put where to disable the Nochex payment option if the cart total including delivery is greater than £250?

Thanks in advance

17 Aug 2011, 2:11 PM
#2
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

Does anyone have the answer?

17 Aug 2011, 2:22 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

If this were the Check/Money Order, I would customize the file:
/includes/modules/payment/moneyorder.php

with the code in red:

      if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID;
      }

// bof: disable on orders over $250.00
if (!IS_ADMIN_FLAG) {
  global $cart;
  if ($_SESSION['cart']->show_total() > 250) {
    $this-enabled = false;
  }
}
// eof: disable on orders over $250.00

      if (is_object($order)) $this->update_status();

You should be able to do something similar with NoChex ...

17 Aug 2011, 2:52 PM
#4
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

Thanks for the quick reply.

I did that and it stopped my shop/index.php?main_page=checkout_payment page from loading even with a very small order

Heres the section of nochex_apc.php I put your code in. Shall I post the whole php file?

$this->description = MODULE_PAYMENT_NOCHEX_TEXT_DESCRIPTION;
$this->sort_order = MODULE_PAYMENT_NOCHEX_SORT_ORDER;
$this->enabled = ((MODULE_PAYMENT_NOCHEX_STATUS == 'True') ? true : false);
if ((int)MODULE_PAYMENT_NOCHEX_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_NOCHEX_ORDER_STATUS_ID;
}

// bof: disable on orders over $250.00

if (!IS_ADMIN_FLAG) {
global $cart;
if ($_SESSION['cart']->show_total() > 250) {
$this-enabled = false;
}
}
// eof: disable on orders over $250.00

if (is_object($order)) $this->update_status();
$this->form_action_url = 'https://secure.nochex.com/';

}
/**

  • calculate zone matches and flag settings to determine whether this module should display to customers or not
    *
    */
    function update_status() {
    global $order, $db;
17 Aug 2011, 2:57 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

Sorry I have a typo ... :blush:

This line:

$this-enabled = false;

should read:

$this->enabled = false;
17 Aug 2011, 3:09 PM
#6
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

Just one little ">" lol

Ok it works to a fasion but it seems to take the cart sub total not the total inc postage. I can work round this by lowering the 250 specified in the code but is it an easy fix to make it work of total cart value

£243.22
Sub-Total:

£8.50
Postage and Packing (2nd Class Royal Mail):

£251.72
Total:

Payment Method

Please select a payment method for this order.
Credit or Debit Card (Secure Payment) "this is nochex option"

Checkout with PayPal Check out using your PayPal account

17 Aug 2011, 3:21 PM
#7
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

See if this code in red works better:

      if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID;
      }

// bof: disable on orders over $250.00
if (!IS_ADMIN_FLAG) {
  global $order;
  if ($order->info['total'] > 250) {
    $this->enabled = false;
  }
}
// eof: disable on orders over $250.00

      if (is_object($order)) $this->update_status();
17 Aug 2011, 3:25 PM
#8
congerman avatar

congerman

Zen Follower

Join Date:
Oct 2008
Posts:
392
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

Worked like a charm. Thank you ever so much for your time and knowledge.

17 Aug 2011, 3:26 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

You are most welcome ... thanks for the update that this is working for you ...

9 Jan 2012, 5:34 AM
#10
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

i want to show the payment module only if the order total >$100,

i add this, but it doesn't work

// bof: enable on orders over 100
if (!IS_ADMIN_FLAG) {
  global $order;
  if ($order->info['total'] < 100) {
    $this->enabled = false;
  }
}
// eof: enable on orders over 100

what do i modify it?

9 Jan 2012, 5:57 AM
#11
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

i tried "disable the module if over 100", it works,

// bof: disable on orders over 100 
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if ($order->info['total'] > 100) { 
    $this->enabled = false; 
  } 
} 
// eof: disable on orders over 100  

but "enable the module only if over 100" doesn't work,

// bof: enable on orders over 100 
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if ($order->info['total'] < 100) { 
    $this->enabled = false; 
  } 
} 
// eof: enable on orders over 100  

if add the code above, it replace the module code "moneyorder" with "GV/DC",
i guess cause this code in classes/orders.php

'payment_module_code' => (($this->info['payment_module_code'] == '' and $this->info['payment_method'] == '') ? PAYMENT_MODULE_GV : $this->info['payment_module_code']), 

but i dont know what do i modify the code to disable the payment module if the order total not over than $100

9 Jan 2012, 2:34 PM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

That is because it is already false and if you want to enable for < 100 you would need to do it the other way ...

However, since you need the enable on the module to be true ... you should use the test for when to turn it off ...

// bof: disable on orders less than 100 
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if ($order->info['total'] < 100) { 
    $this->enabled = false; 
  } 
} 
// eof: disable on orders less than 100 

Now just setup the module like normal and have it start out enabled ...

If the order is < 100, it will turn off ...

9 Jan 2012, 3:02 PM
#13
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

sorry, i'm not sure what do i modify the code

i want to disable moneyorder if order total less than $100, enable it if over $100,

here's my code, but it changes the payment module moneyorder to GV/DC,

if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {
        $this->order_status = MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID;
      }

// bof: disable on orders less than 100 
if (!IS_ADMIN_FLAG) { 
  global $order; 
  if ($order->info['total'] < 100) { 
    $this->enabled = false; 
  } 
} 
// eof: disable on orders less than 100
      if (is_object($order)) $this->update_status();
9 Jan 2012, 5:33 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

Go to Modules ... Payments ... and install the Check/Money Order moneyorder payment module ...

Edit the file:
/includes/modules/payment/moneyorder.php

and add the code in RED:

      $this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);

// bof: disable on orders less than 100
if (!IS_ADMIN_FLAG) {
  global $order;
  if ($order->info['total'] < 100) {
    $this->enabled = false;
  }
}
// eof: disable on orders less than 100

      if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {

That is it ...

I think you put your code too low in the file ...

9 Jan 2012, 7:06 PM
#15
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

Ajeh:

Go to Modules ... Payments ... and install the Check/Money Order moneyorder payment module ...

Edit the file:
/includes/modules/payment/moneyorder.php

and add the code in RED:

  $this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);

// bof: disable on orders less than 100
if (!IS_ADMIN_FLAG) {
global $order;
if ($order->info['total'] < 100) {
$this->enabled = false;
}
}
// eof: disable on orders less than 100

  if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {
> 
> That is it ...
> 
> I think you put your code too low in the file ...

i tried this, it seems the code above is very correct, but still no luck, the payment module changed to GV/DC again, so weired, any ideas?
9 Jan 2012, 7:14 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

Do you have an URL to your site where we can perhaps try this and see what it is doing? :unsure:

9 Jan 2012, 8:54 PM
#17
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

now i don't think it's a problem of my site, cause just now, i tried installing another site, then i got the same problem, then i installed one more site, also the same problem, the module changed to GV/DC, all the site are running with 1.39h english version, when i tried it on a 1.38 site, it works. the code couldn't work on 1.39h?

9 Jan 2012, 9:08 PM
#18
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

I am not sure what to tell you ... this has nothing to do with GV/DC and should just disable the Check/Money Order ...

What payment modules are installed?

Do you have any installed that are not enabled?

Do you have Sort Orders on any of them?

9 Jan 2012, 9:43 PM
#19
inception avatar

inception

New Zenner

Join Date:
Jun 2011
Posts:
63
Plugin Contributions:
0

Re: Do not show Nochex option if cart total over 250

yes i know, its nothing to do with GV/DC, i guess it turned to GV/DC just cause the code in classes/orders.php
'payment_module_code' => (($this->info['payment_module_code'] == '' and $this->info['payment_method'] == '') ? PAYMENT_MODULE_GV : $this->info['payment_module_code']),

but i dont know why the payment_module_code and payment_method turned to empty after adding the code to moneyorder.php

to make sure its not my current site problem, i installed a new zencart store, totally new without any other addons or mod, just open modules/payment/moneyorder.php,
between the black code, i added the red code as below,

$this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);

// bof: disable on orders less than 100
if (!IS_ADMIN_FLAG) {
  global $order;
  if ($order->info['total'] < 100) {
    $this->enabled = false;
  }
}
// eof: disable on orders less than 100

      if ((int)MODULE_PAYMENT_MONEYORDER_ORDER_STATUS_ID > 0) {

from admin, i set the payment module moneyorder configuration just as before, yes i set it to true and set the sort order
then i placed an order and went to admin/orders.php page, the payment code display as "GV/DC" which should have been "moneyorder", in the order confirmation email, it also displays GV/DC payment text.

the red code above doesn't work for 1.39h, i tried it on 1.38, it worked.

9 Jan 2012, 10:07 PM
#20
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Do not show Nochex option if cart total over 250

I am on v1.5 ...

I only install the Check/Money Order moneyorder ...

I add less than $100 in the cart and on the checkout_payment I see:

Payment Method

Sorry, we are not accepting payments from your region at this time.
Please contact us for alternate arrangements.

I cannot get beyond this poing in the checkout ...