paypal plugin 2.2

electragiselle

No avatar

2007-10-17 21:59

This is a revamped version of the plugin for 2.0 in this post.
http://opensolution.org/Quick.Cart/forum/?p=readTopic&nr=3454


Step 1
edit >>>> lang/en.php

/*
* Name of fields in forms
*/
//--------- PayPal Start
$lang[Currency_Code] = 'Currency Code';
$lang['PayPal_Email'] = 'PayPal Email';
//--------- PayPal Finish

Step 2
edit >>>>actions_client/orders.php

if( isset( $iOrder ) && is_numeric( $iOrder ) ){
if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){
if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){
saveOrder( $iOrder, $_POST );

//--------- paypal star
$aData = throwOrder( $iOrder );
listBasket( $iOrder);
$aData['fSummary'] = sprintf( '%01.2f', $aData['fCourierPrice'] + $aList['fSummary'] );
if( !empty($config['PayPal_email']) ){
$content .= $tpl->tbHtml( 'orders_summary.tpl', 'ORDER_PAYPAL' );
}
else
//-------- paypal end

$aData = throwOrder( $iOrder );
$sBasketList = listBasket( $iOrder, 'orders_summary.tpl' );

Step 3
edit >>>>templates/orders_summary.tpl

<div id="ok">
$lang[Order_finished]<br />

//--------- paypal start
<form target="paypal" name="_$iOrder" action="https://www.paypal.com/cgi-bin/webscr";; method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="$config[PayPal_email]">
<input type="hidden" name="item_name" value="Order ID $iOrder">
<input type="hidden" name="currency_code" value="$config[currency_code]">
<input type="hidden" name="amount" value="$aList[fSummary]">
<input type="hidden" name="shipping" value="$aData[fCourierPrice]">
<input type="hidden" name="no_note" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but6.gif";; name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
//--------- paypal start

</div>


Step 4
edit >>>>config/general.php

$config['version'] = '2.2';
//--------- paypal star
$config['PayPal_email'] = "edit_your_paypal@email";
$config['currency_code'] = "USD";
//-------- paypal end

Step 5
edit >>>>templates/admin/config_form.tpl

</tr>
//--------- paypal star
<tr>
<th>
$lang[PayPal_Email]
</th>
<td>
<input type="text" name="PayPal email" value="$config[PayPal_email]" size="35" />
</td>
</tr>
<tr>
<th>
$lang[Currency_Code]
</th>
<td>
<input type="text" name="currency code" value="$config[currency_code]" size="5" maxlength="3" />
</td>
</tr>
//-------- paypal end
<tr>
<th>
$lang[Start_page]

» Quick.Cart v2.x

idaryl

Avatar: idaryl

2007-10-20 10:09

Tried this out and I received this: No block: ORDER_PAYPAL in file: templates/orders_summary.tpl

Is there a step missing?

idaryl

Avatar: idaryl

2007-10-22 03:58

Hello electragiselle,

do you have an idea of what I can do to remedy this?

idaryl

Avatar: idaryl

2007-10-25 13:51

Does anyone else have this problem and fixed it?

electragiselle

No avatar

2007-11-25 03:54

EDIT TO ABOVE FIX:

(New) Step 3
edit >>>>templates/orders_summary.tpl

<div id="ok">
$lang[Order_finished]<br />

//--------- paypal start

<!-- BEGIN ORDER_PAYPAL -->
<form target="paypal" name="_$iOrder" action="https://www.paypal.com/cgi-bin/webscr";;; method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="$config[PayPal_email]">
<input type="hidden" name="item_name" value="Order ID $iOrder">
<input type="hidden" name="currency_code" value="$config[currency_code]">
<input type="hidden" name="amount" value="$aList[fSummary]">
<input type="hidden" name="shipping" value="$aData[fCourierPrice]">
<input type="hidden" name="no_note" value="1">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but6.gif";;; name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<!-- END ORDER_PAYPAL -->

//--------- paypal start

</div>

danbrouwers

No avatar

2007-12-23 03:41

I am using QuickCart v2.2
I installed stormy's original plugin for PayPal v2.0
Then I edited that with electragiselle's revamped version

The problem that I am having is that when I click on the "my cart" button or the "add to backet" button, I get a parse error message.......

Parse error: parse error, unexpected $ in /homepages/20/d91060311/htdocs/greatamericansportswear/actions_client/orders.php on line 104

I have already ftp the entire shopping cart website in binary mode.

I am hoping that I just mis-typed the code in the orders.php file
I have listed my code for that page below, would someone look at it and see what I've done wrong please? Thanks :)

<?php
require_once DIR_CORE.'couriers-'.DB_TYPE.'.php';
require_once DIR_CORE.'couriers.php';

require_once DIR_CORE.'orders-'.DB_TYPE.'.php';
require_once DIR_CORE.'orders.php';

require_once DIR_CORE.'products-'.DB_TYPE.'.php';
require_once DIR_CORE.'products.php';

if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) && !empty( $_COOKIE['sOrderQC_'.LANGUAGE] ) ){
$aOrder = throwOrderMd5( $_COOKIE['sOrderQC_'.LANGUAGE] );
if( isset( $aOrder ) && is_array( $aOrder ) )
$_SESSION['iOrderSession_'.LANGUAGE] = $aOrder[0];
setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 );
}

if( $a == 'Basket' ){

if( isset( $sOption ) ){
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];
else{
$_SESSION['iOrderSession_'.LANGUAGE] = $iOrder = throwOrderIdTemp( );
}

if( $sOption == 'add' ){
if( isset( $iProduct ) && is_numeric( $iProduct ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity >= 1 ){
addOrderProduct( $iProduct, $iQuantity, $iOrder );
}
header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' );
exit;
}
elseif( $sOption == 'del' ){
if( isset( $iElement ) && is_numeric( $iElement ) )
delOrderElement( $iOrder, $iElement );
}
elseif( isset( $_POST['saveBasket'] ) ){
if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
saveOrderProducts( $_POST );
}

if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) )
setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 );

setCookie( 'sOrderQC_'.LANGUAGE, md5( $iOrder ), time( ) + 86400 );
if( !isset( $_COOKIE['sLanguage'] ) ){
setCookie( 'sLanguage', LANGUAGE, time( ) + 86400 );
}
}
elseif( $sOption == 'save' ){
if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
saveOrderProducts( $_POST );
}

if( isset( $_POST['sSave'] ) ){
header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' );
exit;
}
}
}
else{
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];
}

if( isset( $iOrder ) && is_numeric( $iOrder ) )
$sBasketList = listBasket( $iOrder, 'orders_basket.tpl' );

if( !empty( $sBasketList ) )
$content .= $sBasketList;
else
$content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );

}
elseif( $a == 'Delivery' ){
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];

if( isset( $iOrder ) && is_numeric( $iOrder ) ){
if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){
if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){
saveOrder( $iOrder, $_POST );
//----------paypal star
$aData = throwOrder( $iOrder );
listBasket( $iOrder);
$aData['fSummary'] = sprintf( '%01.2f', $aData['fCourierPrice'] + $aList['fSummary'] );
if( !empty($config['PayPal_email']) ){
$content .= $tpl->tbHtml( 'orders_summary.tpl', 'ORDER_PAYPAL' );
}
else
//-------- paypal end

$aData = throworder( $iOrder );
$sBasketList = listBasket( $iOrder, 'orders_summary.tpl' );
if( !empty( $sBasketList ) ){
$sCouriersSelect = listCouriers( 'couriers_select.tpl' );
$sBasketList .= $tpl->tbHtml( 'orders_delivery.tpl', 'COURIER' );
$content .= $tpl->tbHtml( 'orders_delivery.tpl', 'FORM' );
}
else
$content .= $tpl->tbHtml( 'orders_delivery.tpl', 'NOT_FOUND' );
}
?>

Dan Brouwers

danbrouwers

No avatar

2007-12-27 02:08

problem solved.........:)

Dan Brouwers

idaryl

Avatar: idaryl

2007-12-27 03:03

and..... what was the problem.......?

danbrouwers

No avatar

2007-12-29 20:52

The problem that I was having is that when I clicked on the "my cart" button or the "add to backet" button, I got a parse error message.......

Parse error: parse error, unexpected $ in /homepages/20/d91060311/htdocs/greatamericansportswear/actions_client/orders.php on line 104

I discovered that when I copied and pasted the revamped code that I left out 2 lines of code which included 2 "({" brackets which created the error message.

I have since corrected my code and my cart is working properly now !

Dan Brouwers

idaryl

Avatar: idaryl

2007-12-30 00:33

OK, so what did you leave out - I'm trying this as well

danbrouwers

No avatar

2007-12-31 19:23

idaryl,

I don't remember which 2 lines of code that I left out.
That was several days ago....at my age it feels like a year ago!

So I will copy and paste that whole page for "actions_client/orders.php" to make it easier for all of us.
This is for QCv2.2
-----------------------------------------------------------------------------------------
<?php
require_once DIR_CORE.'couriers-'.DB_TYPE.'.php';
require_once DIR_CORE.'couriers.php';

require_once DIR_CORE.'orders-'.DB_TYPE.'.php';
require_once DIR_CORE.'orders.php';

require_once DIR_CORE.'products-'.DB_TYPE.'.php';
require_once DIR_CORE.'products.php';

if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) && !empty( $_COOKIE['sOrderQC_'.LANGUAGE] ) ){
$aOrder = throwOrderMd5( $_COOKIE['sOrderQC_'.LANGUAGE] );
if( isset( $aOrder ) && is_array( $aOrder ) )
$_SESSION['iOrderSession_'.LANGUAGE] = $aOrder[0];
setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 );
}

if( $a == 'Basket' ){

if( isset( $sOption ) ){
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];
else{
$_SESSION['iOrderSession_'.LANGUAGE] = $iOrder = throwOrderIdTemp( );
}

if( $sOption == 'add' ){
if( isset( $iProduct ) && is_numeric( $iProduct ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity >= 1 ){
addOrderProduct( $iProduct, $iQuantity, $iOrder );
}
header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersBasket' );
exit;
}
elseif( $sOption == 'del' ){
if( isset( $iElement ) && is_numeric( $iElement ) )
delOrderElement( $iOrder, $iElement );
}
elseif( isset( $_POST['saveBasket'] ) ){
if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
saveOrderProducts( $_POST );
}

if( isset( $_COOKIE['sOrderQC_'.LANGUAGE] ) )
setCookie( 'sOrderQC_'.LANGUAGE, null, time( ) - 1 );

setCookie( 'sOrderQC_'.LANGUAGE, md5( $iOrder ), time( ) + 86400 );
if( !isset( $_COOKIE['sLanguage'] ) ){
setCookie( 'sLanguage', LANGUAGE, time( ) + 86400 );
}
}
elseif( $sOption == 'save' ){
if( isset( $_POST['aElements'] ) && is_array( $_POST['aElements'] ) ){
saveOrderProducts( $_POST );
}

if( isset( $_POST['sSave'] ) ){
header( 'Location: '.$_SERVER['PHP_SELF'].'?p=ordersDelivery' );
exit;
}
}
}
else{
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];
}

if( isset( $iOrder ) && is_numeric( $iOrder ) )
$sBasketList = listBasket( $iOrder, 'orders_basket.tpl' );

if( !empty( $sBasketList ) )
$content .= $sBasketList;
else
$content .= $tpl->tbHtml( 'orders_basket.tpl', 'NOT_FOUND' );

}
elseif( $a == 'Delivery' ){
if( isset( $_SESSION['iOrderSession_'.LANGUAGE] ) )
$iOrder = $_SESSION['iOrderSession_'.LANGUAGE];

if( isset( $iOrder ) && is_numeric( $iOrder ) ){
if( isset( $_POST['sOption'] ) && $_POST['sOption'] == 'send' ){
if( checkOrderFields( $_POST ) === true && checkOrderProducts( $iOrder ) === true ){
saveOrder( $iOrder, $_POST );
//----------paypal star
$aData = throwOrder( $iOrder );
listBasket( $iOrder);
$aData['fSummary'] = sprintf( '%01.2f', $aData['fCourierPrice'] + $aList['fSummary'] );
if( !empty($config['PayPal_email']) ){
$content .= $tpl->tbHtml( 'orders_summary.tpl', 'ORDER_PAYPAL' );
}
else
//-------- paypal end
$aData = throwOrder( $iOrder);


}

}
else{
$sBasketList = listBasket( $iOrder, 'orders_summary.tpl' );
if( !empty( $sBasketList ) ){
$sCouriersSelect = listCouriers( 'couriers_select.tpl' );
$sBasketList .= $tpl->tbHtml( 'orders_delivery.tpl', 'COURIER' );
$content .= $tpl->tbHtml( 'orders_delivery.tpl', 'FORM' );
}
else
$content .= $tpl->tbHtml( 'orders_delivery.tpl', 'NOT_FOUND' );
}
}
else
$content .= $tpl->tbHtml( 'orders_delivery.tpl', 'NOT_FOUND' );
}
?>
-------------------------------------------------------------------------------------------------
I hope this helps!
I have so many irons-in-the-fire that I do not get to check this discussion board as often as I would like to, so if I do not answer right away.....I will as soon as I can.
I am not a developer or a professional programmer, but I am currently trying to teach myself how to integrate UPS Tracking and an Actual Shipping Cost Verifier into my QCv2.2 website. As soon as I accomplish that, i will come back and post my code as a new topic.

Dan Brouwers

Back to top
about us | contact