How to remove "Add Album to Cart" from album pages

cwyenberg

Joined: 2005-08-28
Posts: 8
Posted: Tue, 2005-09-06 20:25

I assume this is a modification to getitemlinks in the modules/cart/module.inc file but I have no idea what that modification is.

Would someone please advise how exactly to accomplish this mod.

Thanks,
CW

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-06 23:07

you still want to keep the "add item to cart" link on item pages and in the item action list drop down menus?

 
cwyenberg

Joined: 2005-08-28
Posts: 8
Posted: Tue, 2005-09-06 23:35

Yes...I only wish to remove the little cart image and the link "Add Album to Cart" from the root album page. I still wish to be able to add individual photos to a cart...just not an entire album. For my needs, this option is counter-productive. Most often I find that users click this link first there by filling up their cart with the entire album.

I'd really prefer to see a "Go to Album" link instead but will be happy if I can just remove the Add to Album option from the root album page.

Thanks,
CW

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-09-07 00:08

i don't think this can be done in .tpl files at the moment, as far as i remember, the cart item links are not named (no named index).

thus you'd have to add a few lines of code in modules/cart/module.inc in getItemLinks(), add a condition (isa('GalleryDataItem', $item)) or something like that to only add the link for data items (photos, movies, ...). albums are not data items, that's what you want.

 
cwyenberg

Joined: 2005-08-28
Posts: 8
Posted: Wed, 2005-09-07 01:31

I appreciate the input...thanks! Problem is, I am not a coder. I can find the appropriate files and can make changes with direction...but thta's it. Where exactly would I add the condition (isa('GalleryDataItem', $item)) in module.inc? Can you please be more specific.

Thanks very much...I really appreciate your efforts here.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-09-07 06:00

change
foreach ($items as $item) {
to
foreach ($items as $item) { if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {

and a bit below that change } to } }

edit by valiant, 2005/09/27: fixed html entities

 
cwyenberg

Joined: 2005-08-28
Posts: 8
Posted: Wed, 2005-09-07 16:11

:-))...yeah baby! Worked like a charm. Now I'll just have to remember how to make these changes when there is an update.

Thanks mindless...

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-09-07 16:44

nope, you don't have to remember.

just never change the .tpl files directly, instead copy them into a local/ subdirectory in the same directory and edit the .tpl file there.
when upgrading, keep the local folders and that's it.

notice: when you use unzip or tar -xzf to unarchive g2 over your existing gallery2 folder, it will keep the local folders automatically.
if you need to upload the gallery2 files with a ftp client, it's up to the ftp client whether it keeps the local folders or not.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-09-07 17:33

(this is a *.inc change so yes, in this case you do have to remember...)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-09-07 17:38

oops, confused two different threads, sorry.

 
yolise

Joined: 2005-09-27
Posts: 24
Posted: Tue, 2005-09-27 12:53

That code seems to have some extra html characters in it ((, etc). Those aren't right, are they? Can someone type out the code without those?

Or is this correct:

foreach ($items as $item) { if (!GalleryUtilities)) is($item, 'GalleryAlbumItem')) {

Not entirely sure what { and : are as I'm not getting any results from google for those, but I assume they are brackets?

And can I confirm that this will remove the 'Add album to Cart' thing from the main page?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-27 13:03

check again, i've fixed the code. it was converted to html entities in our website move.

 
yolise

Joined: 2005-09-27
Posts: 24
Posted: Tue, 2005-09-27 13:12

Cool. Thanks. I wondered why the person who asked the question didn't query that!

 
yolise

Joined: 2005-09-27
Posts: 24
Posted: Tue, 2005-09-27 13:16

Shoot. Throws an error now. Here's the whole snippet. What have I done wrong?

/* Fetch child counts */
	$itemIds = array();
	foreach ($items as $item) { if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {
	    $itemIds[] = $item->getId();
	}}
 
yolise

Joined: 2005-09-27
Posts: 24
Posted: Tue, 2005-09-27 13:20

Oh, here's the error detail (s'all greek to me):

Error (ERROR_BAD_PARAMETER) : 
in modules/core/classes/helpers/GalleryItemHelper_simple.class at line 93 (gallerystatus::error) 
in modules/core/classes/GalleryCoreApi.class at line 1326 (galleryitemhelper_simple::fetchchildcounts) 
in modules/core/module.inc at line 87 (gallerycoreapi::fetchchildcounts) 
in modules/core/classes/GalleryTheme.class at line 1361 (coremodule::getitemlinks) 
in themes/matrix/theme.inc at line 75 (matrixtheme::loadcommontemplatedata) 
in modules/core/classes/GalleryTheme.class at line 900 (matrixtheme::showalbumpage) 
in modules/core/classes/GalleryView.class at line 285 (matrixtheme::loadtemplate) 
in main.php at line 287 (showitemview::doloadtemplate) 
in main.php at line 87
in main.php at line 80
 
chiarelli

Joined: 2004-01-30
Posts: 14
Posted: Mon, 2005-10-03 16:28

I have followed the changes above, but don't see any change (the add album to cart link is not removed)

Here is my code in the cart/module.inc:

/**
* @see GalleryModule::getItemLinks()
*/
function getItemLinks($items, $wantsDetailedLinks, $permissions) {
$links = array();
foreach ($items as $item) { if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {
$itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false));
/* Specific translations: _('Add Album To Cart') _('Add Photo To Cart') */
$links[$item->getId()][] =
array('text' => $this->_translate(array('text' => 'Add %s To Cart',
'arg1' => $itemTypeNames[0]), $itemTypeNames[2]),
'params' => array('controller' => 'cart.AddToCart',
'itemId' => $item->getId(),
'return' => true));
}}

return array(GalleryStatus::success(), $links);
}
}
?>

Is there something that is over-riding the change I made to the modules.inc?

Any assistance in removing the "Add Albums to cart" link would be greatly appreciatated.

 
vdd

Joined: 2005-08-11
Posts: 134
Posted: Mon, 2005-10-03 19:23

Make a change in modules/cart/module.inc. Change: foreach ($items as $item) {
into: foreach ($items as $item) { if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {
and a bit below that change } to }}

This is what the forum told me to do and it works!
Now I figured out that this true for the zip download module and cart module .

When I added the Checkout modules I got again the "add album to cart " sentence on the album pages and I am waiting for an answer here in the forum to remove this.

I also want to change the text "Add Photo To Cart " from the zip and cart module in something like "add Photo to download cart" other wise you have
"Add Photo To Cart " (from the zip and cart module) and "add photo to cart" (from the checkout modules) on your Item Page.

 
saidts

Joined: 2007-03-27
Posts: 44
Posted: Wed, 2007-09-12 19:06

To see the changes, remember to clear saved pages if you are using Gallery2 acceleration!
Go in 'Site Admin'/'Performance' and hit 'Clear Saved Pages'.

 
HLee

Joined: 2007-03-06
Posts: 12
Posted: Mon, 2007-10-01 14:43

Does anyone know how to do the same thing
(remove the little cart image and the link "Add Album to Cart" from the root album page. I still wish to be able to add individual photos to a cart...just not an entire album).
I am not using the "Cart" Module
I am using the "checkoutpaypal" Module

 
loupierrot

Joined: 2006-12-06
Posts: 31
Posted: Wed, 2007-10-24 12:21

Hello,
I did try to do the same on my site, but the "add album to cart" from the root album and in any album is still visible. Here is the code I transformed as it is written. But it doesn't work.

Quote:

/**
* @see GalleryModule::getItemLinks()
*/
function getItemLinks($items, $wantsDetailedLinks, $permissions) {
$links = array();
foreach ($items as $item) { if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {
if (isset($permissions[$item->getId()]['cart.add'])) {
$itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false));
/* Specific translations: _('Add Album To Cart') _('Add Photo To Cart') */
$links[$item->getId()][] =
array('text' => $this->_translate(
array('text' => 'Add %s To Cart',
'arg1' => $itemTypeNames[0]), $itemTypeNames[2]),
'params' => array('controller' => 'cart.AddToCart',
'itemId' => $item->getId(), 'return' => true));
}
}

return array(null, $links);
}
} }
?>

Thanks in advance for helping me...
Pierre

 
loupierrot

Joined: 2006-12-06
Posts: 31
Posted: Wed, 2007-10-24 12:24

by the way, here is the visible page :
http://www.e-photographie.net/gallery2/gallery2/main.php

 
derickson

Joined: 2006-04-13
Posts: 32
Posted: Wed, 2009-04-01 19:46

Great Thread, I modified this code:
Before

	foreach (
	    if (isset($permissions[$item->getId()]['cart.add'])) {
		$itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false));
		if (false) {
		    /* Specific translations: */ _('Add Album To Cart'); _('Add Photo To Cart');
		}

After

	foreach ($items as $item) {if (!GalleryUtilities::isA($item, 'GalleryAlbumItem')) {
	    if (isset($permissions[$item->getId()]['cart.add'])) {
		$itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false));
		if (false) {
		    /* Specific translations: */ _('Add Album To Cart'); _('Add Photo To Cart');
		}}
 
bolzano

Joined: 2006-11-18
Posts: 7
Posted: Fri, 2009-08-28 18:07

Hello,

Update about this hack because I've found a problem :

I have the cart module installed.
I have some albums only allowed to registered users
Anonymous users are not allowed to use cart module, only registered users
I don't want that users (registered and anonymous of course) can see "Put album in the cart"
I've done the hack above, it's OK for registered users BUT :
I have realised that anonymous users sees "download %s to cart" in galleries (not in the root album but in thumbnails...) Strange...

So, how to fix that ?

Thanks.....