Sub Menu
Links Menu
Online Users

In total there are 654 users online :: 2 registered, 0 hidden and 652 guests

Most users ever online was 1091 on Wed Aug 16, 2023 5:27 pm

Registered users: Bing [Bot], Google [Bot] based on users active over the past 60 minutes

Need help with php code

General discussion of anything. Discuss a topic in and out of IntegraMOD

Moderator: Integra Moderator

Need help with php code

PostAuthor: .QUACK.Major.Pain » Sun Sep 16, 2007 8:25 am

Need help with code for something other the integramod.

I'm working on another site - an oscommerce store, and having difficulty with making changes.
I'm no good with this other than to follow the instructions given.

This is the original page:

<php>


The instructions are to make changes between the single quotes, so I changed the file to this:

<?php
/*
$Id: shipping.php,v 1.4 2002/11/19 01:48:08 dgw_ Exp $

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

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
*/

define('NAVBAR_TITLE', 'Shipping & Returns');
define('HEADING_TITLE', 'Shipping & Returns');

define('TEXT_INFORMATION', '
<table>
<tr>
<td><br><b>BEFORE DOING PURCHASE FROM STUFFUPFORGRAB.COM - PLEASE REMEMBER TO READ THE FOLLOWING CONDITIONS:</b><br>
<br>- STUFFUPFORGRAB.COM IS NOT RESPONSIBLE FOR THE CUSTOMER'S DECISION WHEN PURCHASING ITEMS FROM ONLINE. STUFFUPFORGRAB.COM ADVISES TO RESEARCH ITEMS YOU ARE PLANNING TO BUY BEFORE PURCHASING, SINCE STUFFUPFORGRAB.COM WILL TAKE NO RESPONSIBILITY FOR CUSTOMERS IGNORANCE WHEN BUYING.
<br>- ALL ITEMS ARE FINAL SALE (THIS DOES NOT NECESSARILY MEAN THERE IS NO WARRANTY) REGARDLESS OF WHETHER OR NOT YOU ARE SATISFIED WITH THE ITEM
<br>- ANY RETURNS, EXCHANGES, AND CREDIT, MUST HAVE THE ORIGINAL RECIEPT. NO RECIEPT NO WARRANTY, NO EXCEPTIONS
<br>- ANY PHYSICAL DAMAGE VOIDS ALL WARRANTIES, NO EXCEPTIONS
<br>- ALL IMAGES OR URLS SHOWN ARE FOR REFERENCE ONLY. THE ACTUAL PRODUCTS MAY BE DIFFERENT
<br><br><b>Stuffupforgrab.com Policies:</b><br>
<br><b>1.0 DOA (Dead on Arrival) or defective Replacements:</b>
<br>Buyer must contact seller within 10 days of receiving item to report DOA item.
<br>If a product is DOA within the first 10 days of receiving the customer must return the item with the original receipt for inspection. Upon confirmation of DOA a replacement will be provided to the customer.<br>
<br><b>Reasons for denying replacement:</b><br>
<br>- Returning an item without the original receipt.
<br>- Returning an item without the original BOX and its original content.
<br>- Product return date exceeding the 10 days DOA replacement period.
<br>- Products with SERIAL NUMBER which does not match SERIAL NUMBER on package or invoice.
<br>- Any item that has any PHYSICAL DAMAGE will not be accepted.
<br>- Any components missing from the original box.<br>
<br><b>2.0 Returns Policy:</b></br>
<br>All returned items regardless whether it is OPENED or UNOPENED will be subjected to a 15% restocking fee.
<br>- Must be within 10 days from date of receiving item and accompanied with the original receipt.
<br>- All Service Charges, Assembling Charges, Diagnostic Charges, Transaction Processing Fees and Shipping Charges are non-refundable.
<br>- ALL SPECIAL ORDER ITEMS ARE NON-REFUNDABLE OR EXCHANGABLE
<br>All Online payments using PayPal will take 48 hours for processing the refund.
<br>All EXCHANGES are upon approval by the manager Stuffupforgrab.com. NO EXCEPTIONS
<br>
</td>
</tr>
</table>
');
?>


When I access the page, I get this error:

Parse error: syntax error, unexpected T_STRING in /home4/stuffupf/public_html/catalog/includes/languages/english/shipping.php on line 20


I don't know enough to figure out what I have done incorrect.

I have other addon mods, I might need help with if someone is interested in looking at.
Last edited by .QUACK.Major.Pain on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

.QUACK.Major.Pain
Sr Integra Member
Sr Integra Member
 
Posts: 986
Likes: 0 post
Liked in: 0 post
Joined: Sat Jan 27, 2007 10:15 am
Cash on hand: 0.00

Re: Need help with php code

PostAuthor: sanji » Sun Sep 16, 2007 4:44 pm

Check this part :

STUFFUPFORGRAB.COM IS NOT RESPONSIBLE FOR THE CUSTOMER'S DECISION WHEN PURCHASING ITEMS FROM ONLINE


You have an apostrophe after the CUSTOMER, which is considered in php as the end of the define function... You have to put a backslash before this, like :

CUSTOMER'S DECISION WHEN


Check the whole text, there might be other errors...

Personally, I would recommend zen-cart instead <img>

sanji
Last edited by sanji on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
[img]http://www.secret-japan.com/forum/images/banners/fuji%20secret-japan%2088x31.gif[/img] [url=http]Secret Japan[/url] : discover Japan off the beaten tracks

sanji
Sr Integra Member
Sr Integra Member
 
Posts: 291
Likes: 0 post
Liked in: 0 post
Joined: Wed Apr 12, 2006 8:18 pm
Cash on hand: 0.00

Re: Need help with php code

PostAuthor: .QUACK.Major.Pain » Sun Sep 16, 2007 5:46 pm

Thanks - that was it.

I'll check out zen - having difficulty with payment, shipping and quantity mods.
Last edited by .QUACK.Major.Pain on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

.QUACK.Major.Pain
Sr Integra Member
Sr Integra Member
 
Posts: 986
Likes: 0 post
Liked in: 0 post
Joined: Sat Jan 27, 2007 10:15 am
Cash on hand: 0.00

Re: Need help with php code

PostAuthor: .QUACK.Major.Pain » Tue Sep 18, 2007 2:11 pm

Thanks for the reference Sanji - much better site with Zen - Their install package comes with a the mods preinstalled.

I have another problem with the code for a CanPar shipping mod.
Here's the original code:


<?php
/*
canpar.php,v 0.1 2006/07/22 10:52:11 hpdl Exp $

ORIGINAL CANPAR SCRIPT
Copyright (c) 2006 J. B. Wallace ([url=mailto:kevinalwayswins@hotmail.com]kevinalwayswins@hotmail.com[/url]) 2006.8.25
Adaption copyright CyKron Interactive (http://www.cykron.com).

MODIFICATION TO WORK WITH ZEN CART
Copyright (c) 2007 Steve Oliveira (<a>oliveira.steve@gmail.com</a>) 7/24/2007

Released under the GNU General Public License
*/

class canpar {
var $code, $title, $de.scription, $icon, $enabled;

// class constructor
function canpar() {
global $order;

$this->code = 'canpar';
$this->title = MODULE_SHIPPING_CANPAR_TEXT_TITLE;
$this->de.scription = MODULE_SHIPPING_CANPAR_TEXT_DESCRIPTION;
$this->mark_up = MODULE_SHIPPING_CANPAR_MARK_UP;
$this->sort_order = MODULE_SHIPPING_CANPAR_SORT_ORDER;
$this->icon = DIR_WS_IMAGES . 'icons/canpar.gif';
$this->tax_class = MODULE_SHIPPING_CANPAR_TAX_CLASS;
$this->enabled = ((MODULE_SHIPPING_CANPAR_STATUS == 'True') ? true : false);

}

// class methods
function quote($method = '') {
global $order, $shipping_weight,$shipping_num_boxes, $total_weight, $boxcount, $handling_cp, $cart;

$srcFSA = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 3);
$desFSA = substr(strtoupper($order->delivery['postcode']), 0, 3);

$srcFSA1stLetter = substr(strtoupper(SHIPPING_ORIGIN_ZIP), 0, 1);
$desFSA1stLetter = substr(strtoupper($order->delivery['postcode']), 0, 1);

$PkgWT = $shipping_weight;

//Connect to CanPar here to get quote, and parse XML.
$request = join('&', array('service=1',
'quantity=' . $shipping_num_boxes,
'unit=L',
'origin=' . $srcFSA,
'dest=' . $desFSA,
'cod=0',
'weight=' . intval($shipping_weight),
'put=0',
'xc=0',
'dec=0'));

$body = file_get_contents('http://www.canpar.com/CanparRateXML/BaseRateXML.jsp?' . $request);
$body_array = explode("<BaseRate>", $body);

$ShippingCost = $body_array[1];
$ShippingCost = ereg_replace('</BaseRate></CanparCharges></CanparRate>', '', $ShippingCost);


if (strlen($ErrMsg) == 0) {
$this->quotes = array('id' => $this->code,
'module' => MODULE_SHIPPING_CANPAR_TEXT_TITLE,
'methods' => array(array('id' => $this->code,
'title' => MODULE_SHIPPING_CANPAR_TEXT_WAY,
'cost' => $ShippingCost)));
} else {
$this->quotes = array('module' => $this->title,
'error' => $ErrMsg);
}

if ($this->tax_class > 0) {
$this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
}

if (zen_not_null($this->icon)) $this->quotes['icon'] = zen_image($this->icon, $this->title, null, null, 'align="middle"');

return $this->quotes;
}

function check() {
global $db;
if (!isset($this->_check)) {
$check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_CANPAR_STATUS'");
$this->_check = $check_query->RecordCount();
}
return $this->_check;
}

function install() {
global $db;
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_de.scription, configuration_group_id, sort_order, set_function, date_added) values ('Enable CANPAR Shipping', 'MODULE_SHIPPING_CANPAR_STATUS', 'True', 'Do you want to offer CANPAR rate shipping?', '6', '0', 'zen_cfg_select_option(array('True', 'False'), ', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_de.scription, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_de.scription, configuration_group_id, sort_order, date_added) values ('Mark Up', 'MODULE_SHIPPING_CANPAR_MARK_UP', '1', 'Use the following mark-up on the shipping list fees.', '6', '0', now())");
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_de.scription, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_CANPAR_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}

function remove() {
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

function keys() {
return array('MODULE_SHIPPING_CANPAR_STATUS', 'MODULE_SHIPPING_CANPAR_TAX_CLASS', 'MODULE_SHIPPING_CANPAR_MARK_UP', 'MODULE_SHIPPING_CANPAR_SORT_ORDER');
}
}
?>




This is the part I have the problem with:

//Connect to CanPar here to get quote, and parse XML.
$request = join('&', array('service=1',
'quantity=' . $shipping_num_boxes,
'unit=L',
'origin=' . $srcFSA,
'dest=' . $desFSA,
'cod=0',
'weight=' . intval($shipping_weight),
'put=0',
'xc=0',
'dec=0'));


The part that refers to 'service' - 1 is for shipping in Canada only and 2 is for shipping in USA only.
I want to use this for both countries, but I don't know coding enough to re-write this myself.

CanPar only uses the first 3 characters of a postal/zip code. eg. Canada = K8A - US = 123
I think what needs to be done, is to check the 1st and/or 3rd character of the SHIPPING_ORIGIN_ZIP to see if they are letter or number value.

I was thinking something like:



If ((ZIP(1) equal or less than 9) AND (ZIP(3) equal or less than 9))

Then //for US

//Connect to CanPar here to get quote, and parse XML.
$request = join('&', array('service=2',
'quantity=' . $shipping_num_boxes,
'unit=L',
'origin=' . $srcFSA,
'dest=' . $desFSA,
'cod=0',
'weight=' . intval($shipping_weight),
'put=0',
'xc=0',
'dec=0'));

ELSE //for CAN

//Connect to CanPar here to get quote, and parse XML.
$request = join('&', array('service=1',
'quantity=' . $shipping_num_boxes,
'unit=L',
'origin=' . $srcFSA,
'dest=' . $desFSA,
'cod=0',
'weight=' . intval($shipping_weight),
'put=0',
'xc=0',
'dec=0'));


That's my idea, but not knowing coding, I don't know how to implement it.

Could someone help me out and re-write the original code to make this work.

Please... Please...

Thanks in advance for any suggestions.
Last edited by .QUACK.Major.Pain on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

.QUACK.Major.Pain
Sr Integra Member
Sr Integra Member
 
Posts: 986
Likes: 0 post
Liked in: 0 post
Joined: Sat Jan 27, 2007 10:15 am
Cash on hand: 0.00

PostAuthor: sanji » Tue Sep 18, 2007 2:44 pm

This is far above my abilities. Did you find this contribution directly on the zen-cart.com web site? I would encourage you to post your question there, people are quite helpful and might have already seen this issue...

sanji
Last edited by sanji on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
[img]http://www.secret-japan.com/forum/images/banners/fuji%20secret-japan%2088x31.gif[/img] [url=http]Secret Japan[/url] : discover Japan off the beaten tracks

sanji
Sr Integra Member
Sr Integra Member
 
Posts: 291
Likes: 0 post
Liked in: 0 post
Joined: Wed Apr 12, 2006 8:18 pm
Cash on hand: 0.00

Re: Need help with php code

PostAuthor: .QUACK.Major.Pain » Tue Sep 18, 2007 4:07 pm

Yea - I posted but no answer yet. The guys a pretty helpful here, so thought I'd give it a try.
Last edited by .QUACK.Major.Pain on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.

.QUACK.Major.Pain
Sr Integra Member
Sr Integra Member
 
Posts: 986
Likes: 0 post
Liked in: 0 post
Joined: Sat Jan 27, 2007 10:15 am
Cash on hand: 0.00


Return to General Discussion

Who is online

Registered users: Bing [Bot], Google [Bot]

cron