[Solved]: Send individual item detail to paypal shopping cart [Solved]: Send individual item detail to paypal shopping cart
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

[Solved]: Send individual item detail to paypal shopping cart

Started by WesG, February 15, 2008, 08:27:23 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

WesG

Hi Stramm (or anyone else who can help me),

I have implemented your Shopping Cart plugin (http://forum.coppermine-gallery.net/index.php?topic=32231.0) to link my site to Paypal for selling images (I prefer the simplicity and layout of your plugin rather than the other mods that are out there for Paypal integration). I am rather new to coding, and I have been trying to figure out how to send individual item detail (rather than simply the whole order as one entity) to Paypal when "uploading" the shopping cart.

The best I can figure out from Paypal's site and information is that the "pay with paypal" form in photo_shop_checkout.php, which looks like this:


                        <form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="item_name" value="{$CONFIG['gallery_name']} {$lang_photoshop['order_id']} {$order_id}">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
<input type="hidden" name="amount" value="{$item_price}">
<input type="hidden" name="shipping" value="{$shipping_price}">
<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>


should involve different "item_name" for each separate item (eg. "item_name_1", "item_name_2", etc, each with a corresponding amount/price) and then the individual items that have been ordered will be listed in the Paypal shopping cart, along with their corresponding prices.

The new photo_shop_checkout.php form would then look something like this:

                        <form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="item_name_1 " value="some Item 1 Name">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
<input type="hidden" name="amount_1 " value="some Item 1 Price">
                        <input type="hidden" name="item_name_2 " value="some Item 2 Name">
                        <input type="hidden" name="amount_2 " value="some Item 2 Price">
<input type="hidden" name="shipping" value="{$shipping_price}">
<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>


Is there a way to call information from the user's shopping cart that could be inserted into this form as individual items with corresponding prices?
Thanks in advance for your help.

~WesG

Stramm

you can find teh answer in photo_shop_checkout.php as well

function photoshop_prep_data gets called nearly at the beginning and creates arrays that hold all the cart data ($shop_array_cd and $shop_array_photos)
$shop_array is the merged version

Now have a look at the function photoshop_add_data, it shows you how to use extract all necessary info from the array $shop_array. Basically you could use that function as is and just need to remove the sql insert statements and replace them with your desired code.

WesG

Stramm,
Thanks for your quick response. I apologize for my lack of coding knowledge, but could you provide a bit more help or specifics?
Just to make sure I have made my goal clear, I want to be able to have the title or filename of the photos a user purchases inserted into the Paypal Form (shown in my previous post) as the value  for name="item_name_1". Then I would need the corresponding price for "item_name_1" be inserted into the Form as the value for name="amount_1". The title/filename of the second photo in the user's shopping cart would then go under "item_name_2" and "amount_2".

I am reading as much as I can about PHP and MySQL, but I can't seem to figure out exactly what variables or code I need to insert into that form.
You suggested using the function photoshop_add_data. Do I copy that function and rename it, then use the sql Insert Into statement to update the title or filename field of the database? I assume this could then be called in the Paypal Form?

I guess what is confusing me is that the photoshop_add_data function seems to extract the information (eg. price) for all photos in the TABLE_SHOP database, but how do I call up the price for the first photo in the Paypal Form (for amount_1) and the price for the second photo (for amount_2), etc?

Any help would be greatly appreciated. In the meantime, I'll keep trying to figure it out and learning more PHP.
Thanks,
WesG

Stramm

The shopping basket stores the data in a cookie (session) as long the user hasn't confirmed teh order. Then the data's getting saved in the sql database.

Read my above post again. The array $shop_array contains the info from the cookie. The function photoshop_add_data stores the data from that array in the database. That's exactly what you're asking for... except of course the sql insert statements (save to database commands).

WesG

Stramm,

I have toiled for a few days now, but I have been unable to produce code that works. I keep getting an error (on the Paypal page) that says, "Your shopping cart is empty" once I click the Pay Now button after confirming the order. I may be way off, but here is what I did. I tried writing a function (see below):function photoshop_add_paypal_data($shop_data, $order_id){
global $CONFIG, $SHOP_CONFIG, $cd_price, $cd_counter, $discount, $shipping_price;

$otime = time();
$picture_total = 0;
foreach ($shop_data as $key => $item_id) {
$pid = $item_id['pid'];
$amount = $item_id['amount'];

if ($item_id['id']=="CD") {
$size = "CD";
$price = $cd_price[1];
} else {
$size = $SHOP_CONFIG[$item_id['id']]['name'];
$price = $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");

    while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);

$picture_total = ($picture_total+$price*$amount);
}

$results = cpg_db_query ("INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`pid`, `quantity`, `price`) VALUES ('$pid', '$amount', '$price')");
}
return $results;
}

I call this function just before the Paypal shopping cart form in photo_shop_checkout, which now looks like this: //pay with paypal
photoshop_add_paypal_data($shop_array, $order_id);
if ($CONFIG['photo_shop_paypal_enable']) {
$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>

<form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="item_name_1" value="{$pid[0]}">
<input type="hidden" name="amount_1" value="{$price[0]}">
<input type="hidden" name="quantity_1" value="{$amount[0]}">
<input type="hidden" name="item_name_2" value="{$pid[1]}">
<input type="hidden" name="amount_2" value="{$price[1]}">
<input type="hidden" name="quantity_2" value="{$amount[1]}">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
<input type="hidden" name="shipping" value="{$shipping_price}">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" border="0" name="submit" alt="Pay with PayPal OR credit card!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

EOT;
}

I could be doing lots of things wrong, I just don't know what they are or how to fix them. Can you help?
Thanks for your patience with me.

~WesG

Stramm

try that... the only additional stuff I added is a query that grabs the image title and displays it in the Paypal cart

//pay with paypal
if ($CONFIG['photo_shop_paypal_enable']) {
$handling = $shipping_price-$discount;
$paypal_items = "";
$counter = 0;
foreach ($shop_array as $key => $item_id) {
$pid = $item_id['pid'];
$amount = $item_id['amount'];
$counter++;
if ($item_id['id']=="CD") {
$size = "CD";
$price = $cd_price[1];
} else {
$size = $SHOP_CONFIG[$item_id['id']]['name'];
$price = $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");

    while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);

//to grab the image title from the db
$query = cpg_db_query("SELECT title FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$item_id['pid']}");
    $row = mysql_fetch_row($query);
($row[0]) ? $title= $row[0] : $title="No title";
mysql_free_result($row);



$picture_total = ($picture_total+$price*$amount);
}


$paypal_items .= "<input type=\"hidden\" name=\"item_name_{$counter}\" value=\"Title: {$title} - ID: {$pid}\">";
$paypal_items .= "<input type=\"hidden\" name=\"amount_{$counter}\" value=\"{$price}\">";
$paypal_items .= "<input type=\"hidden\" name=\"quantity_{$counter}\" value=\"{$amount}\">";
}

$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>

<form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
{$paypal_items}
<input type="hidden" name="handling_cart" value="{$handling}">

<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>

EOT;
}

WesG

Thank you, Stramm. That worked like a charm! Just what I was looking for. Please mark this thread as solved.

yogiflop

Hello,

it ist possible to display the filename in Paypal instead of the info ??

regards

Stramm

it's even commented in the code
//to grab the image title from the db
$query = cpg_db_query("SELECT title FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$item_id['pid']}");

So it should be enough to replace title with filename (that's from the pictures table the field with the name 'filename', it contains ,like the naming already suggests, the filename).

yogiflop


tgontz

What am I missing here? I would like to use PayPal with this plugin but don't even know where to begin. Based on the version info I thought that I would need to modify the include/gateway.inc.php included (introduced in version 1.2) but I do not have that file in 1.36.

I see in this thread that Wes has a // pay with paypal section in his photo_shop_checkout.php file - where did this come from because I do not have it in my photo_shop_checkout.php file?

Please advise & thanks!

Stramm

Are you sure you're using the shop version 1.3.6 and not the outdated one from the plugin pack? You can download it here http://forum.coppermine-gallery.net/index.php/topic,32231

tgontz

Ahh, you nailed it. I did exactly what you said. While I did download the latest version, that is not what I installed. Instead, foolishly I copied the photo_shop folder from the plugin pack to my gallery installation.

Thanks - your'e awesome!

erika_conn

http://ceconn.com/photo_gallery

Quote from: Stramm on February 21, 2008, 12:29:19 PM
try that... the only additional stuff I added is a query that grabs the image title and displays it in the Paypal cart

//pay with paypal
if ($CONFIG['photo_shop_paypal_enable']) {
$handling = $shipping_price-$discount;
$paypal_items = "";
$counter = 0;
foreach ($shop_array as $key => $item_id) {
$pid = $item_id['pid'];
$amount = $item_id['amount'];
$counter++;
if ($item_id['id']=="CD") {
$size = "CD";
$price = $cd_price[1];
} else {
$size = $SHOP_CONFIG[$item_id['id']]['name'];
$price = $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");

    while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);

//to grab the image title from the db
$query = cpg_db_query("SELECT title FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$item_id['pid']}");
    $row = mysql_fetch_row($query);
($row[0]) ? $title= $row[0] : $title="No title";
mysql_free_result($row);



$picture_total = ($picture_total+$price*$amount);
}


$paypal_items .= "<input type=\"hidden\" name=\"item_name_{$counter}\" value=\"Title: {$title} - ID: {$pid}\">";
$paypal_items .= "<input type=\"hidden\" name=\"amount_{$counter}\" value=\"{$price}\">";
$paypal_items .= "<input type=\"hidden\" name=\"quantity_{$counter}\" value=\"{$amount}\">";
}

$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>

<form action="{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="currency_code" value="{$CONFIG['photo_shop_paypal_currency']}">
{$paypal_items}
<input type="hidden" name="handling_cart" value="{$handling}">

<input type="image" src="{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>

EOT;
}


I tried to copy what you did but after I did that I got this error when clicking on checkout:

Parse error: syntax error, unexpected '}' in /home/cecon46/public_html/photo_gallery/plugins/photo_shop/photo_shop_checkout.php on line 264

When I looked at that line this is what was there: } else {
Where did I err?


erika_conn

Quote from: Nibbler on July 02, 2008, 04:55:57 PM
Attach the complete file.

With Pleasure:
]<?php
/**************************************************
  CPG Photo Shop Plugin for Coppermine Photo Gallery
  *************************************************
  Copyright (c) 2006 Thomas Lange <stramm@gmx.net>
  *************************************************
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  *************************************************
  Coppermine version: 1.4.16
  Photo Shop version: 1.3.6
  $Revision: 1.0 $
  $Author: stramm $
***************************************************/
define('PHOTOSHOP_ORDER_PHP'true);

require(
'include/init.inc.php');
require(
'include/mailer.inc.php');
require(
'include/gateway.inc.php');

if (!
defined('IN_COPPERMINE')) die('Not in Coppermine...');
if (!
USER_ID && $CONFIG['allow_unlogged_access'] == 0cpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);

$lang = isset($USER['lang']) ? $USER['lang'] : $CONFIG['lang'];
if (!
file_exists("plugins/photo_shop/lang/{$lang}.php"))
  
$lang 'english';
require 
"plugins/photo_shop/lang/{$lang}.php";

if (!
defined('IN_COPPERMINE')) die('Not in Coppermine...');
//cart empty??
$cd_counter photoshop_count_items();
if ((
$cd_counter['cd']+$cd_counter['photo']) == ) {
pageheader($lang_photoshop['checkout']);
starttable('100%'$lang_photoshop['checkout'], 1);
msg_box(''$lang_photoshop['cart_empty'], $lang_continue'index.php');
pagefooter();
ob_end_flush();
exit;
}
//if user isn't logged in redirect to shop register/ login page
if(!USER_ID) {
    
photoshop_refresh($_SERVER['PHP_SELF'].'?file=photo_shop/photo_shop_register');
exit;
}
//start html output
pageheader($lang_photoshop['checkout']);
starttable('100%'$lang_photoshop['checkout'], 1);
endtable();
//start all the if else
$cd_price item_price($cd_counter['cd']);
if (
$cd_price[3] == false) { // more CD items than max defined -> warn and show link to cart
echo '<tr><td><br>'.$cd_price[2].'<br>'.$lang_photoshop['goto_cart_cd'].'</td></tr>';
} elseif ((
$_POST['order'] == "confirmed") && (($cd_counter['cd']+$cd_counter['photo']) > )) {
//add to mysql, show confirmation and send email (user+admin)
photoshop_prep_data($shop_array_cd$shop_array_photos);
//order_id++
$results cpg_db_query("SELECT oid FROM {$CONFIG['TABLE_SHOP']} ORDER BY oid DESC LIMIT 1");
$row mysql_fetch_array($results);
$order_id = ++$row['oid'];
mysql_free_result($results);

//merge photo und cd array
$shop_array array_merge($shop_array_photos$shop_array_cd);

//calculate the discount
$discount_calc calculate_discount($cd_price$cd_counter);
$shipping_price_calc calculate_shipping();
$discount number_format($discount_calc,2);
$shipping_price number_format($shipping_price_calc,2);
if (photoshop_add_data($shop_array$order_id)) { // adding data succeeded
//now email the user
//first we prepare the invoice attachment
$invoice '<pre>'//added to make the output more convenient when viewing the email not as text email but html
$invoice .= $lang_photoshop_email_attach_header//in the lang file we could define a header for the invoice
$invoice .= photoshop_create_table($shop_array_photos'photo''text');
$invoice .= photoshop_create_table($shop_array_cd'cd''text');
$invoice .= photoshop_format_price($cd_price$cd_counter'''text');
$invoice .= '</pre>';


if(photoshop_email_the_user($lang_photoshop_email_order.$invoice$lang_photoshop['email_subject_order'])){
//when user got his email, then send to admin
photoshop_email_the_user($lang_photoshop_email_admin.$invoice$lang_photoshop['email_subject_order_admin'], true);

//here we do the integration... we just add the buttons, text etc to the msg_box

$item_price number_format(($cd_price[0]+$cd_price[1]-$discount_calc),2); // - discount (used for paypal, google checkout)
$order_price number_format(($cd_price[0]+$cd_price[1]+$shipping_price_calc-$discount_calc),2);
$msg_box_txt $lang_photoshop['email_sent'];
$msg_box_txt .= '<br><br>'.$lang_photoshop['order_id'].' '.$order_id.', '.$lang_photoshop['total'].' '.$order_price.' '.$lang_photoshop['USD'];


//pay by wire
if ($CONFIG['photo_shop_wire_enable']) {
$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['wire']}<br>

<table>
<tr>
<td>
{$lang_photoshop['bank']}</td>
<td>
{$CONFIG['photo_shop_wire_bank']}</td>
</tr>
<tr>
<td></td>
<td>
{$CONFIG['photo_shop_wire_bank_address']}</td>
</tr>
<tr>
<td>
{$lang_photoshop['routing']}</td>
<td>
{$CONFIG['photo_shop_wire_routing']}</td>
</tr>
<tr>
<td>
{$lang_photoshop['account']}</td>
<td>
{$CONFIG['photo_shop_wire_account']}</td>
</tr>
<tr>
<td>
{$lang_photoshop['swift']}</td>
<td>
{$CONFIG['photo_shop_wire_swift']}</td>
</tr>
</table>
EOT;

}

//pay with paypal
if ($CONFIG['photo_shop_paypal_enable']) {
$handling $shipping_price-$discount;
$paypal_items "";
$counter 0;
foreach ($shop_array as $key => $item_id) {
$pid $item_id['pid'];
$amount $item_id['amount'];
$counter++;
if ($item_id['id']=="CD") {
$size "CD";
$price $cd_price[1];
} else {
$size $SHOP_CONFIG[$item_id['id']]['name'];
$price $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");

    while ($temp_data mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);

//to grab the image title from the db
$query cpg_db_query("SELECT title FROM {$CONFIG['TABLE_PICTURES']} WHERE pid={$item_id['pid']}");
    
$row mysql_fetch_row($query);
($row[0]) ? $title$row[0] : $title="No title";
mysql_free_result($row);



$picture_total = ($picture_total+$price*$amount);
}


$paypal_items .=  "<input type=\"hidden\" name=\"item_name_{$counter}\" value=\"Title: {$title} - ID: {$pid}\">";
$paypal_items .=  "<input type=\"hidden\" name=\"amount_{$counter}\" value=\"{$price}\">";
$paypal_items .=  "<input type=\"hidden\" name=\"quantity_{$counter}\" value=\"{$amount}\">";
}
$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>

<form action="
{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="
{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="currency_code" value="
{$CONFIG['photo_shop_paypal_currency']}">
{$paypal_items}
<input type="hidden" name="handling_cart" value="
{$handling}">

<input type="image" src="
{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>

EOT;
}


if ($CONFIG['photo_shop_paypal_use_ipn'] == '1') {
$paypal_notify_url '<input type="hidden" name="notify_url" value="'.$CONFIG['ecards_more_pic_target'].$CONFIG['photo_shop_paypal_ipn_notify_url'].'">';
$paypal_notify_url .= '<input type="hidden" name="rm" value="2">';
} else $paypal_notify_url '';
if ($CONFIG['photo_shop_tax'] != '') {
$paypal_tax '<input type="hidden" name="tax_cart" value="'.$CONFIG['photo_shop_tax']*$picture_total.'">';
} else $paypal_tax '';
if ($CONFIG['photo_shop_paypal_return_url'] != '') {
$paypal_return_url '<input type="hidden" name="return" value="'.urlencode($CONFIG['ecards_more_pic_target'].$CONFIG['photo_shop_paypal_return_url']).'">';
} else $paypal_return_url '';
if ($CONFIG['photo_shop_paypal_cancel_return_url'] != '') {
$paypal_cancel_return_url '<input type="hidden" name="cancel_return" value="'.urlencode($CONFIG['ecards_more_pic_target'].$CONFIG['photo_shop_paypal_cancel_return_url']).'">';
} else $paypal_cancel_return_url '';

$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['paypal']}<br>

<form action="
{$CONFIG['photo_shop_paypal_form_url']}" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="invoice" value="
{$order_id}">
<input type="hidden" name="business" value="
{$CONFIG['photo_shop_paypal_email']}">
<input type="hidden" name="currency_code" value="
{$CONFIG['photo_shop_paypal_currency']}">
{$paypal_items}
{$paypal_tax}
{$paypal_return_url}
{$paypal_cancel_return_url}
{$paypal_notify_url}
<input type="hidden" name="handling_cart" value="
{$handling}">
<input type="image" src="
{$CONFIG['photo_shop_paypal_image']}" name="submit" alt="Pay with PayPal!">
</form>

EOT;
}
if ($CONFIG['photo_shop_google_enable']) {
$msg_box_txt .= <<<EOT
<br><br>{$lang_photoshop['google']}<br>

<form method="POST" action="https://checkout.google.com/cws/v2/Merchant/
{$CONFIG['photo_shop_google_id']}/checkoutForm" accept-charset="utf-8">
     <input type="image" name="Google Checkout" alt="Fast checkout through Google" src="http://checkout.google.com/buttons/checkout.gif?merchant_id=
{$CONFIG['photo_shop_google_id']}&w={$CONFIG['photo_shop_google_button_width']}&h={$CONFIG['photo_shop_google_button_height']}&style={$CONFIG['photo_shop_google_button_style']}&variant=text&loc={$CONFIG['photo_shop_google_button_loc']}"  height="46" width="180"/>

<input type="hidden" name="item_name_1" value="
{$CONFIG['gallery_name']}"/>
<input type="hidden" name="item_description_1" value="
{$lang_photoshop['order_id']} {$order_id}"/>
<input type="hidden" name="item_quantity_1" value="1"/>
<input type="hidden" name="item_price_1" value="
{$item_price}"/>
<input type="hidden" name="item_currency_1" value="
{$CONFIG['photo_shop_google_currency']}"/>
<input type="hidden" name="ship_method_name_1" value="
{$lang_photoshop['shipping']}"/>
     <input type="hidden" name="ship_method_price_1" value="
{$shipping_price}"/>
</form>

EOT;
}


$msg_box_txt .= '<br><br><br>';


msg_box(''$msg_box_txt$lang_continue'index.php');

//comment out if you don't want the orders to appeare on the order confirmed page
starttable('100%'$lang_photoshop['myorders'], 1);
echo photoshop_create_table($shop_array_photos'photo''html');
echo photoshop_create_table($shop_array_cd'cd''html');
echo photoshop_format_price($cd_price$cd_counter'''html');
endtable();
//now we just need to clear the cookie/ session and done
setcookie($CONFIG['cookie_name'] . '_cart'''time() + 86400 30$CONFIG['cookie_path']);
unset ($_SESSION['photoshop']['cart']);
}



pagefooter();
ob_end_flush();
exit; // we're done here
} else {
//something went wrong
}

} else {
//show the cart contents and price, submit button
echo "<form action='{$_SERVER['PHP_SELF']}?file=photo_shop/photo_shop_checkout' method='post'>";

photoshop_prep_data($shop_array_cd$shop_array_photos);
echo photoshop_create_table($shop_array_photos'photo''html');
echo photoshop_create_table($shop_array_cd'cd''html');
echo photoshop_format_price($cd_price$cd_counter'''html');

echo <<<EOT
                <tr>
                        <td align="left" class="tablef" colspan="7">
                            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                                <tr>
                                    <td width="100%" align="center">
                                        <input type="hidden" name="order" value="confirmed" />
                                        <input type="submit" class="button" name="apply" value="
{$lang_photoshop['send_order']}" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                </tr>
EOT;
}

endtable();
echo 
"</form>";
//printing a pricelist
photoshop_pricelist();
pagefooter();
ob_end_flush();

//functioons
function photoshop_prep_data(&$shop_array_cd, &$shop_array_photos){
$shop_array_photos = array(); //temp array for easier use
$shop_array_cd = array(); //temp array for easier use
foreach ($_SESSION['photoshop']['cart'] as $key => $item_id) {
if ($item_id['id'] == 'CD') {
$shop_array_cd[] = $_SESSION['photoshop']['cart'][$key];
} else {
$shop_array_photos[] = $_SESSION['photoshop']['cart'][$key];
}
}
}

function 
photoshop_create_table($shop_array_photos$type$template){ //we create two basic templates html and text
global $SHOP_CONFIG$CONFIG$lang_photoshop$cd_price;

$out = array();

$out['html'] = '<tr><td><table cellpadding="0" cellspacing="1" width="100%">';
$out['text'] = sprintf("%s\n\n"'');

if ($type == 'photo') {
$out['html'].= <<<EOT
<tr>
<td class="tableh1" width="25%">
{$lang_photoshop['item_id_checkout']}</td>
<td class="tableh1" width="25%">
{$lang_photoshop['type_chckout']}</td>
<td class="tableh1" width="25%">
{$lang_photoshop['amount_checkout']}</td>
<td class="tableh1" width="25%">
{$lang_photoshop['total_checkout']}</td>
</tr>
EOT;
$out['text'].= sprintf("%10.10s\t"$lang_photoshop['item_id_checkout']).sprintf("%15.15s\t",$lang_photoshop['type_chckout']).sprintf("%10.10s\t",$lang_photoshop['amount_checkout']).sprintf("%15.15s\n",$lang_photoshop['total_checkout']);
} elseif(($type == 'cd') && (photoshop_in_array_multi("CD"$shop_array_photos))) {
$out['html'].= <<<EOT
<tr>
<td class="tableh1" width="25%">
{$lang_photoshop['item_id_checkout']}</td>
<td class="tableh1" width="25%">
{$lang_photoshop['type_chckout']}</td>
<td class="tableh1" width="25%">&nbsp;</td>
<td class="tableh1" width="25%">&nbsp;</td>
</tr>
EOT;
$out['text'].= sprintf("%10.10s\t"$lang_photoshop['item_id_checkout']).sprintf("%15.15s\n",$lang_photoshop['type_chckout']);

}
foreach ($shop_array_photos as $key => $item_id) {
$select_columns 'filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, title, aid';

    $result cpg_db_query("SELECT $select_columns from {$CONFIG['TABLE_PICTURES']} WHERE pid='{$item_id['pid']}' LIMIT 1");
    $row mysql_fetch_array($result);

$price $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$row['aid']}");

    while ($temp_data mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);


//html resize thumb
if ($CONFIG['enable_mini_thumbs'] == '1') { // if you use the modpack and have enabled mini thumbs -> these get used instead of html resized thumbs
$thumb_url get_pic_url($row'mini');
    $destWidth $CONFIG['mini_thumb_width'];
    $destHeight $CONFIG['mini_thumb_height'];
} else {
$thumb_url get_pic_url($row'thumb');
$new_size 60;
    $ratio max($row['pwidth'], $row['pheight']) / $new_size;
    $ratio max($ratio1.0);
    $destWidth = (int)($row['pwidth'] / $ratio);
    $destHeight = (int)($row['pheight'] / $ratio);
}

if ($item_id['id'] == 'CD') {
$out['html'].= <<<EOT
<tr>
<td>
<a href="displayimage.php?pos=-
{$item_id['pid']}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a>
</td>
<td>
{$item_id['id']}</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
EOT;

$out['text'].= sprintf("%10.10s\t"$item_id['pid']).sprintf("%15.15s\n",$item_id['id']);

} else {
$price number_format($price*$item_id['amount'],2);
$out['html'].=  <<<EOT
<tr>
<td>
<a href="displayimage.php?pos=-
{$item_id['pid']}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a>
</td>
<td>
{$SHOP_CONFIG[$item_id['id']]['name']}</td>
<td>
{$item_id['amount']}</td>
<td>
{$lang_photoshop['USD']} {$price}</td>
</tr>
EOT;

$out['text'].= sprintf("%10.10s\t"$item_id['pid']).sprintf("%15.15s\t"$SHOP_CONFIG[$item_id['id']]['name']).sprintf("%10.10s\t"$item_id['amount']).sprintf("%15.15s\n",$lang_photoshop['USD'].' '.$price);

}
}
$out['html'] .= "</td></tr></table>";

return $out[$template];
}
function 
photoshop_add_paypal_data($shop_data$order_id){
global $CONFIG$SHOP_CONFIG$cd_price$cd_counter$discount_calc$shipping_price_calc;

$otime time();
$picture_total 0;
foreach ($shop_data as $key => $item_id) {
$pid $item_id['pid'];
$amount $item_id['amount'];

if ($item_id['id']=="CD") {
$size "CD";
$price $cd_price[1];
} else {
$size $SHOP_CONFIG[$item_id['id']]['name'];
$price $SHOP_CONFIG[$item_id['id']]['price'];

//price override
$results cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$item_id['aid']}");

    while ($temp_data mysql_fetch_array($results)) {
if($temp_data['gid']==$SHOP_CONFIG[$item_id['id']]['id'])
$price=$temp_data['price'];
}
mysql_free_result($results);

$picture_total = ($picture_total+$price*$amount);
}

$results cpg_db_query ("INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `pid`, `quantity`, `size`, `price`, `otime`) VALUES ('$order_id', '".USER_ID."', '$pid', '$amount', '$size', '$price', '$otime')");

}
$results2 cpg_db_query ("INSERT INTO `{$CONFIG['TABLE_SHOP']}` (`oid`, `uid`, `cd`, `quantity`, `price`, `otime`) VALUES ('$order_id', '".USER_ID."', '1', '".($cd_counter['cd']+$cd_counter['photo'])."', '".($picture_total+$cd_price[1]+$shipping_price_calc-$discount_calc)."', '$otime')");
return $results;
}


function 
photoshop_email_the_user($message$subject$admin '')
{
global $CONFIG$SHOP_CONFIG$lang_photoshop$cd_price$order_id$discount$shipping_price;

$user_info photoshop_user_details(USER_ID);

if ($admin) {
$user_info['user_email']='admin';
}

$template_vars = array(
'{ORDER_ID}' => $order_id,
'{SITE_NAME}' => $CONFIG['gallery_name'],
'{PRICE}' => number_format(($cd_price[0]+$cd_price[1]+$shipping_price-$discount),2),
'{USER_NAME}' => (USER_NAME),
'{ADMIN}' => $CONFIG['gallery_name'],
'{LINK}' => $CONFIG['ecards_more_pic_target'],
'{USER_PROFILE1}' => $user_info['user_profile1'],
'{USER_PROFILE2}' => $user_info['user_profile2'],
'{USER_PROFILE3}' => $user_info['user_profile3'],
'{USER_PROFILE4}' => $user_info['user_profile4'],
'{USER_PROFILE5}' => $user_info['user_profile5'],
'{USER_PROFILE6}' => $user_info['user_profile6'],
);
$mail_body=nl2br(strtr($message$template_vars));
if(cpg_mail($user_info['user_email'], $subject$mail_body'text/plain'$CONFIG['gallery_name'], $CONFIG['gallery_admin_email'] )) {
return true;
}
return false;
}

function 
photoshop_user_details($id){
global $cpg_udb;
$user_name $cpg_udb->get_user_infos($id);
return $user_name;
}
?>

Nibbler

I followed the instructions and ended up with the attached file. I'm not familiar with this plugin though so no guarantees.

erika_conn

Quote from: Nibbler on July 02, 2008, 06:04:19 PM
I followed the instructions and ended up with the attached file. I'm not familiar with this plugin though so no guarantees.

I'll give it a shot.

erika_conn

Quote from: erika_conn on July 02, 2008, 06:47:13 PM
I'll give it a shot.

Well, something is wrong. I did a test by ordering a picture but nothing showed up to be filled out such as name address email, etc.  I get an email to say I've got an order.  Every order I've tested ends up being stored (archived).

erika_conn

Quote from: erika_conn on July 02, 2008, 07:01:22 PM
Well, something is wrong. I did a test by ordering a picture but nothing showed up to be filled out such as name address email, etc.  I get an email to say I've got an order.  Every order I've tested ends up being stored (archived).
As far as I can tell, the form is missing.  You know, the one you fill out as a purchaser.  The email that was sent to me, the gallery owner said "click to go to the order manager".  That takes me to Order Manager but there is no way to complete the order.  The only thing I can do from there is delete or archive.  Also, there is nothing to tell me any money has been transferred.  Well, an essential part is missing.

The email I got as the purchaser thanked me for the order and told me to transfer the money as soon as possible.  No mention how or anything.

I do appreciate your trying to help, Nibbler.  :)