Advanced search  

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

Pages: [1]   Go Down

Author Topic: Photo Shop Buy Button next to the thumnails  (Read 8730 times)

0 Members and 1 Guest are viewing this topic.

stevenp

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Photo Shop Buy Button next to the thumnails
« on: October 15, 2007, 01:07:50 am »

hello
I want to show the buy-button of the photo shop modul next to every thumbnail in my albums. How can i get this?
greetings steven
« Last Edit: October 17, 2007, 07:23:07 am by GauGau »
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Photo Shop Buy Button next to the thumnails
« Reply #1 on: October 15, 2007, 07:44:33 am »

not related to the modpack... moving to the plugin board

stevenp

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Re: Photo Shop Buy Button next to the thumnails
« Reply #2 on: October 15, 2007, 12:56:06 pm »

hello
any ideas? i want to show the buy-button of the photo shop modul next to every thumbnail in my albums. someone there, who knows what to change?
steven
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Photo Shop Buy Button next to the thumnails
« Reply #4 on: October 16, 2007, 08:09:25 am »

not possible (or better: it's not possible without modifying core code and some more heat on the server -> 1 more query per thumb)

in functions.inc.php find (within function display_thumbnails):
if you use the modpack
Code: [Select]
                        $thumb_list[$i]['pheight'] = $row['pheight'];
if you use a standard coppermine
Code: [Select]
                        $thumb_list[$i]['aid'] = $row['aid'];
below add
Code: [Select]
                //photo_shop plugin hook
$thumb_list[$i] = CPGPluginAPI::filter('display_thumbs',$thumb_list[$i]);

in the plugins codebase.php find
Code: [Select]
// Some filters
$thisplugin->add_filter('thumb_list','photoshop_add_item');
below add
(this is the slightly modified function for displaying the add item dropdown on the intermediate view and the filter call)
Code: [Select]
$thisplugin->add_filter('display_thumbs','photoshop_thumb_add_item');

//add an item to the cart while viewing the thumb list
function photoshop_thumb_add_item($pic_data){
global $CONFIG, $SHOP_CONFIG, $lang_photoshop, $album;

$html = "";
$added = "";
$event = isset($_POST['event']) ? $_POST['event'] : null;

//price override
//if the shop is disabled to show for that album we return $pic_data
//also we check if an override price is set
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$pic_data['aid']}");

    while ($temp_data = mysql_fetch_array($results)) {
if($temp_data['gid']=='-1') return $pic_data;
$SHOP_CONFIG[$temp_data['gid']]['price']=$temp_data['price'];
}
mysql_free_result($results);

switch ($event) {
    case 'add_item':
if(isset($_POST['pid']))
$added = '<center><font color="red">'.$lang_photoshop['added']."!</font></center>";
$duplicate=photoshop_deep_in_array($_POST['pid'],$_POST['item_id'],$_SESSION['photoshop']['cart']);//search array if item is already in cart.. then ++ amount of that item
if(is_numeric($duplicate)){ // only add 1 item if it's for the CD
if ($_SESSION['photoshop']['cart'][$duplicate]['id'] != "CD"){
++$_SESSION['photoshop']['cart'][$duplicate]['amount'];
} else {
//break;
}
} else {
$_SESSION['photoshop']['cart'][] = array(
        'pid' => $_POST['pid'],
        'id' => $_POST['item_id'],
        'amount' => '1',
'aid' => $pic_data['aid'],
        );
}
$cookie_data = base64_encode(serialize($_SESSION['photoshop']['cart']));
setcookie($CONFIG['cookie_name'] . '_cart', $cookie_data, time() + 86400 * 30, $CONFIG['cookie_path']);

break;
}

//loop through the items and create forms

$html .= "<select name=\"item_id\" class=\"listbox_lang\">";
foreach($SHOP_CONFIG as $key => $value) {
if ($value['type'] == 'photo') {
if ($value['price'] != 0) {
$html.="<option value=\"{$value['id']}\">{$value['name']} - {$lang_photoshop['USD']}{$value['price']}</option>";
}
} elseif ($value['type'] == 'cd') {
$cd = true;
}
}
$html .= ($cd) ? "<option value=\"CD\">{$lang_photoshop['CD']}</option>" : '';
$html .="</select>";

($album == 'search') ? $referer = "thumbnails.php?album={$pic_data['aid']}" : $referer = null;

$shop_data =  <<<EOT
<table class="shop_table">
<tr>
<td>
<form action="{$referer}" method="post">
  {$added}{$lang_photoshop['buy']} {$html}
<input type="hidden" value="{$pic_data['pid']}" name="pid" />
<input type="hidden" value="add_item" name="event" />
    <input type="submit" value="{$lang_photoshop['send']}" class="comment_button" />
</form>
</td>
</tr>
</table>

EOT;
$pic_data['caption'] = $shop_data.$pic_data['caption'];
$referer = ($_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''));
if ($added) {
//this is not nice.. but the menu updates before the content. So if you add an item, the basket count can't match
// -> we have to refresh the page twice... can be removed but than the counter is wrong till the user manually reloads
  photoshop_refresh($referer);
echo $added; // redundant ... while refreshing display 'item added'
exit;
}

return $pic_data;
}
« Last Edit: October 16, 2007, 10:27:07 pm by Stramm »
Logged

stevenp

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Re: Photo Shop Buy Button next to the thumnails
« Reply #5 on: October 16, 2007, 04:46:27 pm »

Many thanks at you, stramm!!!
I filled in the code for codebase.php and get this error
"Fatal error: Cannot redeclare photoshop_start() (previously declared in /homepages/17/d124044955/htdocs/cpg/plugins/photo_shop/codebase.php:138) in /homepages/17/d124044955/htdocs/cpg/plugins/photo_shop/codebase.php on line 147"
what's wrong?

In my function.inc.php i don't have a code like this "$thumb_list[$i]['pheight'] = $row['pheight'];", so I don't know where to put this
"//photo_shop plugin hook
$thumb_list[$i] = CPGPluginAPI::filter('display_thumbs',$thumb_list[$i]);"

I hope, i'm not to annoyingly. I only have these problems with my shop and it's really important for me.

Steven
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Photo Shop Buy Button next to the thumnails
« Reply #6 on: October 16, 2007, 04:54:42 pm »

yah.. OK, I've updated above instructions... you only have this part if you use the modpack, so it's my bad

The cause for
Quote
Fatal error: Cannot redeclare photoshop_start()
is that by accident I've copied two functions in the above instr. where there should be only one.
Restart modding using a fresh copy of codebase.php and all should be good.

stevenp

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Re: Photo Shop Buy Button next to the thumnails
« Reply #7 on: October 16, 2007, 07:49:10 pm »

Okay,

the code-tags are inserted. All works, but I still got no cartfuction next to my thumbnails. Did i understand something wrong?
Many thanks for all your help and work.
Steven
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Photo Shop Buy Button next to the thumnails
« Reply #8 on: October 16, 2007, 10:28:39 pm »

yeppers, try again to add the huge block above with the function. Tried it on an umodded CPG and it works smooth as butter

stevenp

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 51
Re: Photo Shop Buy Button next to the thumnails
« Reply #9 on: October 16, 2007, 10:41:49 pm »

hippyyeyahhh,

it works!!!!!!!!!!! GREAT... Thanks a lot!!!!
Please have a last look and try to use ist. After using the add to cart-button. My whole site appears in my coppermine(frame).
Steven
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 20 queries.