Post by mondy » Thu May 13, 2010 12:52 am

b"h

1.) put this code at the end of the theme/defult/template/module/cart.tpl

Code: Select all

<?php if ($ajax) { ?>
<script type="text/javascript"><!--
$(document).ready(function () {
	$('.addtocart').replaceWith('<a onclick="" class="button addtocart">' + $('.addtocart').html() + '</a>');
	
	$('.addtocart').click(function () {
		var pid = this.parentNode.id;
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: $('#'+this.parentNode.id+' :input'),
			success: function (html) {
				$('#module_cart .middle').html(html);
			},	
			complete: function () {
				var image = $('#img_'+pid).offset();
				var cart  = $('#module_cart').offset();
	
				$('#img_'+pid).before('<img src="' + $('#img_'+pid).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
	
				params = {
					top : cart.top + 'px',
					left : cart.left + 'px',
					opacity : 0.0,
					width : $('#module_cart').width(),  
					heigth : $('#module_cart').height()
				};		
	
				$('#temp').animate(params, 'slow', false, function () {
					$('#temp').remove();
				});		
			}			
		});			
	});			
});
//--></script>
<?php } ?>
2.) change the page you want like:
theme/defult/template/common/home.tpl
theme/defult/template/product/category.tpl
theme/defult/template/product/special.tpl
theme/defult/template/product/search.tpl

search a little, about line 38:

Code: Select all

	<div class="heading"><?php echo $text_latest; ?></div>
    <table class="list">
      <?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
      <tr>
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <td style="width: 25%;"><?php if (isset($products[$j])) { ?>
          <?//to adding AddToCart Buttons MO.?>
		  <a href="<?php echo str_replace('&', '&', $products[$j]['href']); ?>"><img id="img_product_<?php echo $products[$j]['id']; ?>" src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" /></a><br />
		  <?//End adding AddToCart Buttons MO.?>
and about line 48:

Code: Select all

		  <? // adding buttons add to cart MO. ?>
		  <form action="index.php?route=checkout/cart" method="post" enctype="multipart/form-data" id="product_<?php echo $products[$j]['id']; ?>">
            <input type="hidden" name="quantity" value="1" />
              <a onclick="$('#product_<?php echo $products[$j]['id']; ?>').submit();"  class="button addtocart"><span><?php echo $button_add_to_cart; ?></span></a>
            <input type="hidden" name="product_id" value="<?php echo $products[$j]['id']; ?>" />
         </form>
		  <? // adding buttons add to cart MO. ?>
          <?php if ($products[$j]['rating']) { ?>
chang the controller of the page like: catalog/controller/common/home.php
(the same for catgory, serach etc.)

about line 5

Code: Select all

				$this->language->load('common/home');
		$this->language->load('product/category'); // Mo add 10.5.2010
		$this->document->title = $this->config->get('config_title');
about line 26

Code: Select all

		
		$this->data['text_latest'] = $this->language->get('text_latest');
		// Mo adding 10.5.2010
		$this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
		$this->data['ajax'] = $this->config->get('cart_ajax');
		// Mo END

about line 93

Code: Select all

				
          	$this->data['products'][] = array(
           	'id' 	   => $result['product_id'],  // Mo add 10.5.2010
			'name'    => $result['name'],
				'model'   => $result['model'],
            	'rating'  => $rating,
				'stars'   => sprintf($this->language->get('text_stars'), $rating),
				'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
            	'price'   => $price,
				'special' => $special,
				'href'    => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/product&product_id=' . $result['product_id'])
          	);
Good luck.

Mo

New member

Posts

Joined
Tue Nov 11, 2008 8:01 am

Post by dramony » Fri May 14, 2010 3:53 pm

can we a sample first? thanks!

Active Member

Posts

Joined
Sat Oct 24, 2009 12:34 pm

Post by mondy » Fri May 14, 2010 5:49 pm

b"h

Here is how it is look like.
(pic is added).

Mo

Attachments

noname.JPG

noname.JPG (67.27 KiB) Viewed 6083 times


New member

Posts

Joined
Tue Nov 11, 2008 8:01 am

Post by helenmarie » Thu Jul 08, 2010 8:57 pm

has anyone tested this? and I cant see the image above to see what it looks like? :)

User avatar
New member

Posts

Joined
Sat Nov 07, 2009 1:05 am

Post by Qphoria » Thu Jul 08, 2010 9:20 pm

if you have 1.4.8 you won't need this as there are already add to cart buttons on those pages

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by helenmarie » Thu Jul 08, 2010 9:33 pm

hiya,

Im running 1.4.7 at the moment. Is there a way to pinch the code from 1.4.8 to get it to work in 1.4.7 or are they completely different?

Thank you

Helen

User avatar
New member

Posts

Joined
Sat Nov 07, 2009 1:05 am

Post by stonehinged » Sat Mar 12, 2011 4:06 am

I have this working on my 1.4.7 category page, see http://www.stonehinged.com/store/handcr ... -bracelets with one small problem. I am seeing this error:

2011-03-11 13:00:50 - PHP Notice: Undefined variable: button_add_to_cart in /home/content/s/t/l/stlockridge/html/store/catalog/view/theme/default/template/product/category.tpl on line 96

Obviously there's an issue with the button I'm still trying to debug, but if anyone knows the quick fix, that would certainly be appreciated.

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by stonehinged » Sat Mar 12, 2011 5:25 am

UPDATE: Figured it out... these two lines

$this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
$this->data['ajax'] = $this->config->get('cart_ajax');

were in the wrong place in my category.php file

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US

Post by Chitranjan » Sun Jul 24, 2011 1:55 am

Hi Qphoria -

I have just luking out the solution how to add "Add to cart Button" in product listing.

i have read your statement :
"if you have 1.4.8 you won't need this as there are already add to cart buttons on those pages"

I have open cart 1.4.9.5

would request you if you could help me out in adding "Add to cart" button at home.tpl, category.tpl, special.tpl

would request you to share the code. step by step.

Thanks in advance

Newbie

Posts

Joined
Tue Jun 28, 2011 4:33 pm
Who is online

Users browsing this forum: No registered users and 5 guests