Forums / Addon Payment Modules / Purchase order module

Purchase order module

Locked

Started by seanscully on 17 May 2006, 3:38 AM · Views: 20,292

Results 41 to 46 of 46
This thread is locked. New replies are disabled.
17 Aug 2011, 4:39 AM
#41
otaraia avatar

otaraia

New Zenner

Join Date:
Mar 2006
Posts:
4
Plugin Contributions:
0

Purchase order module

WaterSlide:

First off, thanks to those who have posted code changes (HTML_POST_VARS to _POST, flakrats suggestion for changing the Order.php email section). I just spent 6 hours with these two old modules on a Zencart v1.3.9d install.

They are both too old to try and install right onto a newer version of Zencart - replacing core files may seem to work at first, but you may find that they will not show the Account Name, Account Number, or PO Number - they won't even save in the database. Just don't bother.

If you have a good text file comparison tool like Beyond Compare, you can quickly look at what this module is trying to do compared to the new way that Zencart works. You will also see that replacing core files will not work. From here you must edit the NEWER zencart files so that they will perform as desired, only copying that which is necessary for the Purchase Order Module. All of the other non-core files may simply be copied over.

I'm not a real good PHP programmer, but I'll go ahead and post the file changes under Knuckle's version - it may be a starting point for some of you, at the very least the three bits of data, Account Name, Account Number, and PO Number save and the emails work so it is still useful.

I just installed the latest Purchase Order Module and it works well....

.... however if you use a PO longer than 12 Characters the SQL has a fit and errors out. The easy fix was to increase the size of the po_number field in the orders table (via MySqlAdmin) but you may want to edit the SQL patch to match whatever the code says is acceptable in terms of field length :-)

17 Aug 2011, 5:08 AM
#42
otaraia avatar

otaraia

New Zenner

Join Date:
Mar 2006
Posts:
4
Plugin Contributions:
0

Re: Purchase order module

otaraia:

I just installed the latest Purchase Order Module and it works well....

.... however if you use a PO longer than 12 Characters the SQL has a fit and errors out. The easy fix was to increase the size of the po_number field in the orders table (via MySqlAdmin) but you may want to edit the SQL patch to match whatever the code says is acceptable in terms of field length :-)

I just made the following change to the po.php located in includes.modules.payment to limit the max PO Size to 14 Characters and not to check for an Account Number :-

// class methods
function javascript_validation() {
$validation_string = 'if (payment_value == "' . $this->code . '") {' . "\n" .
' var account_name = document.checkout_payment.account_name.value;' . "\n" .
' var account_number = document.checkout_payment.account_number.value;' . "\n" .
' var po_number = document.checkout_payment.po_number.value;' . "\n" .
' if (account_name.length == 0) {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PO_TEXT_JS_ACC_NAME . ' ";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" .
' if (po_number.length == 0) {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PO_TEXT_JS_PO_NUMBER . '";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" .
' if (po_number.length >= 15) {' . "\n" .
' error_message = error_message + "' . MODULE_PAYMENT_PO_TEXT_JS_PO_NUMBER_MAX . '";' . "\n" .
' error = 1;' . "\n" .
' }' . "\n" .
'}' . "\n";
return $validation_string;
}

And then in includes.languages.english.modules.payment po.php I added a new line to describe the "Exceeds 14 Characters"

/*
$Id: po.php,v 1.2 2002/11/27 12:00:00 olby Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
*/

define('MODULE_PAYMENT_PO_TEXT_TITLE', 'Purchase Order');
define('MODULE_PAYMENT_PO_TEXT_DESCRIPTION', 'Will you accept Purchase Order?');
define('MODULE_PAYMENT_PO_TEXT_ACCOUNT_NAME', 'Account name:');
define('MODULE_PAYMENT_PO_TEXT_ACCOUNT_NUMBER', 'Account number:');
define('MODULE_PAYMENT_PO_TEXT_PO_NUMBER', 'Purchase Order Nr:');
define('MODULE_PAYMENT_PO_TEXT_EMAIL_FOOTER', 'with the following information:');
define('MODULE_PAYMENT_PO_TEXT_JS_ACC_NAME', 'You forgot to enter the account name (Company).');
define('MODULE_PAYMENT_PO_TEXT_JS_ACC_NUMBER', 'You forgot to enter the your Account Number.');
define('MODULE_PAYMENT_PO_TEXT_JS_PO_NUMBER', 'You forgot to enter your Purchase Order number.');
define('MODULE_PAYMENT_PO_TEXT_JS_PO_NUMBER_MAX', 'Your PO Number Exceeds 14 Characters.');
?>

20 Sep 2011, 7:24 PM
#43
clsmky avatar

clsmky

New Zenner

Join Date:
Jul 2011
Posts:
23
Plugin Contributions:
0

Re: Purchase order module

I just installed this module to give it a shot and it works perfectly. My only issue is that when the email is sent through it doesn't include the Account Number and I actually do need that.

I've searched through the code and it all seems fine and I can't figure out why it doesn't populate it in the email. I haven't changed anything from the files that were included with the module.

Any hints or ideas of where I should look next are very appreciated :D

EDIT: actually the only thing I've changed is add an ID to the input fields to add css styling. Other than that nothing has been changed.

function selection() {

      $selection = array('id' => $this->code,
                         'module' => $this->title,
                         'fields' => array(array('title' => MODULE_PAYMENT_PO_TEXT_ACCOUNT_NAME,
                                                 'field' => zen_draw_input_field('account_name' , '' , 'id="poCompanyName"')),
                                           array('title' => MODULE_PAYMENT_PO_TEXT_ACCOUNT_NUMBER,
                                                 'field' => zen_draw_input_field('account_number' , '' , 'id="poAccountNumber"')),
                                           array('title' => MODULE_PAYMENT_PO_TEXT_PO_NUMBER,
                                                 'field' => zen_draw_input_field('po_number' , '' , 'id="poPurchaseOrderNumber"'))));
20 Sep 2011, 7:42 PM
#44
clsmky avatar

clsmky

New Zenner

Join Date:
Jul 2011
Posts:
23
Plugin Contributions:
0

Re: Purchase order module

Nevermind guys I found the issue. Under the order.php file (\includes\classes\order.php) the account number was nixed for some reason.

Original Code

$email_order .= ($GLOBALS[$payment_class]->email_footer) ? $GLOBALS[$payment_class]->email_footer . "\n" . "Account: " . $this->info['account_name'] . "\n"  . "PO #: " . $this->info['po_number'] . "\n\n" : '';
if ($GLOBALS[$payment_class]->title == 'Purchase Order') {
$html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']]) ? $GLOBALS[$payment_class]->email_footer . "<br>" . "Account: " . $this->info['account_name'] . "<br>" . "PO #: " . $this->info['po_number'] : '');

My code

$email_order .= ($GLOBALS[$payment_class]->email_footer) ? $GLOBALS[$payment_class]->email_footer . "\n" . "Company Name: " . $this->info['account_name'] . "\n" . "Account Number: " . $this->info['account_number'] . "\n" . "PO #: " . $this->info['po_number'] . "\n\n" : '';
if ($GLOBALS[$payment_class]->title == 'Purchase Order') {
$html_msg['PAYMENT_METHOD_FOOTER'] = (is_object($GLOBALS[$_SESSION['payment']]) ? $GLOBALS[$payment_class]->email_footer . "<br>" . "Company Name: " . $this->info['account_name'] . "<br>" . "Account Number: ". $this->info['account_number'] . "<br>" . "PO #: " . $this->info['po_number'] : '');

I changed the "Account:" to "Company Name:" because it makes more sense for me. I also changed it under the defining PHP files so it would make more sense for our clients.

I can't believe I didn't see it two hours ago when I went over the damn code. Thanks anyway guys!

15 Jan 2012, 5:25 AM
#45
glwm avatar

glwm

New Zenner

Join Date:
Jan 2006
Posts:
13
Plugin Contributions:
0

Re: Purchase order module

any word if someone is rewriting this for 1.5? I think there are a lot of folks left hanging...