sergiold
02-16-2009, 04:18 PM
Hi!
I've been working making a gallery to a friend (you can see it in Wiris Gallery (http://www.wirisgallery.com)). One of the addons I've used is the EcoSee Paypal for Pixelpost Addon.
It was really useful but I added some lines in order to copy an image print options to all the other images in the site.
As I saw in this forums, some other people was interested in this functionality so I've decided to share it.
This is how it will look like when finished all modifications:
http://img15.imageshack.us/img15/9757/paypalmodificadolu4.jpg
Code modifications needed
1. Open addons/admin_paypal_cart.php
2. Copy this in line 147
Apply print options to all images? <input type="checkbox" name="change_all_images[]" />
3. Change lines 260-268:
$theid = intval($theid);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
whith this:
if(!isset($_REQUEST["change_all_images"][0])){
$theid = intval($theid);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
}else{
$buscaid="SELECT id FROM {$pixelpost_db_prefix}pixelpost";
$result = mysql_query($buscaid);
while($row=mysql_fetch_row($result)){
$theid = intval($row[0]);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
}
}
That's all!
Instructions
The addon works exactly as before the modifications but if the new checkbox is checked when clicking in Upload or Update image, the options will be added (OR DELETED) in all the images.
If you don't click the checkbox, the options will only affect to the image you are working whith.
I think that's all what I had to say. I hope you find this useful.
I've been working making a gallery to a friend (you can see it in Wiris Gallery (http://www.wirisgallery.com)). One of the addons I've used is the EcoSee Paypal for Pixelpost Addon.
It was really useful but I added some lines in order to copy an image print options to all the other images in the site.
As I saw in this forums, some other people was interested in this functionality so I've decided to share it.
This is how it will look like when finished all modifications:
http://img15.imageshack.us/img15/9757/paypalmodificadolu4.jpg
Code modifications needed
1. Open addons/admin_paypal_cart.php
2. Copy this in line 147
Apply print options to all images? <input type="checkbox" name="change_all_images[]" />
3. Change lines 260-268:
$theid = intval($theid);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
whith this:
if(!isset($_REQUEST["change_all_images"][0])){
$theid = intval($theid);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
}else{
$buscaid="SELECT id FROM {$pixelpost_db_prefix}pixelpost";
$result = mysql_query($buscaid);
while($row=mysql_fetch_row($result)){
$theid = intval($row[0]);
$query = "DELETE FROM {$pixelpost_db_prefix}paypalcardprintoptions WHERE id_image = $theid";
mysql_query($query);
foreach ($options as $opt) {
$query = "INSERT INTO {$pixelpost_db_prefix}paypalcardprintoptions
VALUES('" . mysql_real_escape_string($theid) . "', {$opt['width']}, {$opt['height']}, {$opt['price']}, '" . mysql_real_escape_string($opt['options']) . "')";
mysql_query($query);
}
}
}
That's all!
Instructions
The addon works exactly as before the modifications but if the new checkbox is checked when clicking in Upload or Update image, the options will be added (OR DELETED) in all the images.
If you don't click the checkbox, the options will only affect to the image you are working whith.
I think that's all what I had to say. I hope you find this useful.