Extension "checkout": Go to last Image after click "Add to Cart"
Standard Toaster
Joined: 2008-04-27
Posts: 2 |
Posted: Tue, 2011-01-04 22:57 |
Hi everybody I'm trying for hours to fix a little problem. I'm not a real programmer but can put things together as I need them. You don't need to know checkout to help me out. Just a little PHP and/or Gallery2 knowledge. ;-) The aim I installed the checkout-Plugin in Gallery2. I integrated the Gallery in Typo3 with the appropiate Extension: http://typo3.org/extensions/repository/view/gallery2/current/ It's faster for the visitor of the gallery to have all pictures on one page. So there are about 100 pictures on one page listed among each other. Now the customer can scroll down and click on the "Add to cart"-Button of a picture she/he likes. After that the browser add the picture to the cart and jumps back to the top auf the page. If the visitor added picture 70 to cart and wants to go on in this album she/he has to scroll all the way down to picture 70. After a view addings it's getting annoying. Now what I want checkout to do is going back to the added picture in the "album" view. my solutions (not finished) I've been trying a bit to solve this problem. My possible solution: Extending the "Add to Cart" link with the parameter "#10087" (ID of the Image) To set the parameter 'id=10087' as an ancher in the code at the picture works easly. I just need the link getting run. The link for "Add to cart" which is generated by checkout is the following: http://www.domain.ch/199.html?g2_controller=checkout.AddToCart&g2_itemId=10087&g2_return=/199.html?g2_itemId=14& The link must be: http://www.domain.ch/199.html?g2_controller=checkout.AddToCart&g2_itemId=10087&g2_return=/199.html?g2_itemId=14❧ This link is outputed by the following line in theme/matrix/templates/album.tpl: (near line 122) The link itself is generated by the following line in modules/checkout/module.inc: (line 845) line 845 /** * @see GalleryModule::getItemLinks() */ function getItemLinks($items, $wantsDetailedLinks, $permissions) { list ($ret, $alwaysShow) = GalleryCoreApi::getPluginParameter('module', 'checkout', 'alwaysShowAddToCart'); if ($ret) { return $ret; } $links = array(); foreach ($items as $item) { if (isset($wantsDetailedLinks[$item->getId()]) || $alwaysShow) { if ( ( $item->getCanContainChildren() && isset($permissions[$item->getId()]['checkout.purchaseAlbum'])) || ( !$item->getCanContainChildren() && isset ($permissions[$item->getId()]['checkout.purchase'])) ) { $itemTypeNames = $item->itemTypeName(); $links[$item->getId()][] = array('text' => $this->translate(array('text' => 'Add %s To Cart', 'arg1' => $itemTypeNames[0])), line 862 'params' => array('controller' => 'checkout.AddToCart', 'itemId' => $item->getId(), line 864 'return' => 1)); } } } return array(null, $links); }
If you look at the link you see that every parameter in it is the same as the lines 862 to 864 with a "g2_" before. So I thought I could expand the "'return' => 1" as followed: This does not work. I guess "1" is a fixed integer which is checked and controlled by an other function in the core of gallery. The code tells this at line 845: /** * @see GalleryModule::getItemLinks() */ Now I'm at the edge of my knowledge and need some help. Summary of my solution If you think this is a bad hack. Yes it is! :D I know this would be a nice idea for the Bug tracker of the checkout module. But I need a workaround earlier than the next release of Checkout... Questions 1. Do you know a better solution to get my idea work. (chapter "The aim") 2. Do you know how I could expand the link of the "Add to cart" button near the Picture? (http://www.domain.ch/199.html?g2_controller=checkout.AddToCart&g2_itemId=10087&g2_return=/199.html?g2_itemId=14❧) bottom line Thank you a lot for your ideas or other possible ways how I reach my aim. Greetings from Switzerland Michael System variables My system variables are as followed. It's German. But I think you get the main things. |
|