Fórum OpenCart Brasil

Por um e-commerce livre, confiável e profissional

Suporte geral sobre problemas técnicos para OpenCart v1.x.
#49800
Alguém pode me ajudar?

Eu gostaria de mudar a função do botão na categoria de produtos de "comprar" pra visualizar
Eu dei uma pesquisada por aí e encontrei essa solução

CODE: SELECT ALL
<a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a>


Replace With:

CODE: SELECT ALL
<a href="<?php echo $product['href']; ?>" class="button"><span>view product</span></a>

porém meu tema está um pouco diferente a linha addToCart

está assim:

<div class="desc"><?php echo $product['description']; ?></div>
<div class="buttons">
<a class="button" onclick="addToCart('<?php echo $product['product_id']; ?>');"><?php echo $button_cart; ?></a>
<a href="" class="button-icon" onclick="addToWishList('<?php echo $product['product_id']; ?>'); return false;">
<span class="icon icon-wish"></span><span><?php echo $button_wishlist; ?></span>
</a>
#49804
Se você for modificar diretamente no template é só utilizar da forma abaixo.

<div class="desc"><?php echo $product['description']; ?></div>
<div class="buttons">
<a href="<?php echo $product['href']; ?>" class="button"><span>view product</span></a>
<a href="" class="button-icon" onclick="addToWishList('<?php echo $product['product_id']; ?>'); return false;">
<span class="icon icon-wish"></span><span><?php echo $button_wishlist; ?></span>
</a>
#49807
Fiz um teste aqui e funciona perfeitamente, você deve fazer a mudança no arquivo "catalog/view/theme/default/template/product/category.tpl", essa mudança serve para substituir o botão "comprar" por "Visualizar" no produto listado quando você clica em uma categoria.

Deve substituir:

<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />

Por:

<a href="<?php echo $product['href']; ?>" class="button"><span>Visualizar produto</span></a>
#49812
o arquivo categoria do meu tema está bem diferente
Código: Selecionar todos
<?php echo $header; ?>
<div class="ribbon breadcrumb">
    <div class="top"></div>
    <div class="pivot">
        <div class="center">
            <h1><?php echo $heading_title; ?></h1>
            <?php foreach ($breadcrumbs as $breadcrumb) { ?>
            	<?php if ($breadcrumb['separator'] != '') { ?><span>\</span><?php } ?>
                <a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
            <?php } ?>
        </div>
    </div>
    <div class="bottom"></div>
</div>
<div class="pivot">
	<div id="content">
    	<?php echo $content_top; ?>
		<?php echo $column_left; ?>
        <?php echo $column_right; ?>

        <div id="content-center">
        	<?php if ($thumb || $description) { ?>
                <section class="category-info">
                	<?php if ($thumb) { ?><div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>"></div><?php } ?>
                    <?php if ($description) { ?><?php echo $description; ?><?php } ?>
                </section>
            <?php } ?>
            
            <?php if ($categories) { ?>
                <section class="category-list">
                    <h2><?php echo $text_refine; ?></h2>
                    <?php if (count($categories) <= 5){ ?>
                    	<ul class="column4 list">
                        	<?php foreach ($categories as $category) { ?>
                                <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
                            <?php } ?>
                        </ul>
                    <?php } else { ?>
                    	<?php for ($i = 0; $i < count($categories);) { ?>
                        	<?php $j = $i + ceil(count($categories) / 3); ?>
                            <ul class="column4 list">
                            	<?php for (; $i < $j; $i++) { ?>
                                	<?php if (isset($categories[$i])) { ?><li><a href="<?php echo $categories[$i]['href']; ?>"><?php echo $categories[$i]['name']; ?></a></li><?php } ?>
								<?php } ?>
                            </ul>
                        <?php } ?>
                    <?php } ?>
                </section>
            <?php } ?>
            
            <?php if ($products) { ?>
                <section class="product-filter">
                    <span class="combo-button"><a onclick="display('list');" title="<?php echo $text_list; ?>" class="active"><div class="icon icon-list"></div></a><a onclick="display('grid');" title="<?php echo $text_grid; ?>"><div class="icon icon-grid"></div></a></span>
                    <span class="product-compare"><a href="<?php echo $compare; ?>" id="compare-total"><?php echo $text_compare; ?></a></span>
                    
                    <div class="options">
                        <span class="sort">
                            <?php echo $text_sort; ?><select onchange="location = this.value;">
                             	<?php foreach ($sorts as $sorts) { ?>
                                	<?php if ($sorts['value'] == $sort . '-' . $order) { ?>
                                		<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
                                    <?php } else { ?>
                                    	<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
                                    <?php } ?>
                                <?php } ?>   
                            </select>
                        </span>
                        <span class="limit">
                            <?php echo $text_limit; ?><select onchange="location = this.value;">
                                <?php foreach ($limits as $limits) { ?>
                                    <?php if ($limits['value'] == $limit) { ?>
                                    	<option value="<?php echo $limits['href']; ?>" selected="selected"><?php echo $limits['text']; ?></option>
                                    <?php } else { ?>
                                    	<option value="<?php echo $limits['href']; ?>"><?php echo $limits['text']; ?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select>
                        </span>
                    </div>
                </section>


                <section id="products" class="rows">
                	<?php foreach ($products as $product) { ?><div class="row">
                    	<?php if ($product['thumb']) { ?>
                        	<a href="<?php echo $product['href']; ?>" class="image">
                            	<img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>">
                            </a>
                        <?php } ?>
                        <div class="name">
                        	<?php if ($product['special']) { ?><span class="tag tag-sale">Sale</span><?php } ?><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a>
                        </div>
                        <?php if ($product['rating']) { ?>
                        	<div class="rating"><img src="catalog/view/theme/oceanic/images/ratio-small-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
                        <?php } ?>
                        <?php if ($product['price']) { ?>
                            <div class="price">
                            	<?php if (!$product['special']) { ?>
                                	<?php echo $product['price']; ?>
        						<?php } else { ?>
                                	<span class="old"><?php echo $product['price']; ?></span> <span class="new"><?php echo $product['special']; ?></span>
                                <?php } ?>
                            </div>
                        <?php } ?>
                        <div class="desc"><?php echo $product['description']; ?></div>
                        
                        
<div class="buttons">
<a href="<?php echo $product['href']; ?>" class="button"><span>view product</span></a>
<a href="" class="button-icon" onclick="addToWishList('<?php echo $product['product_id']; ?>'); return false;">
<span class="icon icon-wish"></span><span><?php echo $button_wishlist; ?></span>
</a>


                        </div>
                    </div><?php } ?>
                </section>
                <div class="pagination"><?php echo $pagination; ?></div>
            <?php } ?>
            
            <?php if (!$categories && !$products) { ?>
                <section class="standart">
                    <?php echo $text_empty; ?><br><br>
                    <div class="buttons">
                        <div class="left"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
                    </div>
                </section>
            <?php } ?>
        </div>
        
        <?php echo $content_bottom; ?>
    </div>
</div>

<script type="text/javascript"><!--
function display(view){
	if (view == 'list'){
		if($('#products').hasClass('rows')) return;
		
		$('.product-filter .combo-button a:first').addClass('active');
		$('.product-filter .combo-button a:last').removeClass('active');
		
		$('#products').addClass('rows').removeClass('grid');
		$('#products > div').each(function(index, element){
			var image 	= ($('.image', element).html() != null) ? '<a href="' + $('.image', element).attr('href') + '" class="image">' + $('.image', element).html() + '</a>' : '';
			var price 	= ($('.price', element).html() != null) ? '<div class="price">' + $('.price', element).html()  + '</div>' : '';
			var rating 	= ($('.rating', element).html() != null) ? '<div class="rating">' + $('.rating', element).html()  + '</div>' : '';
			var tagSale = ($('.ribbon-sale', element).html() != null) ? '<span class="tag tag-sale">Sale</span>' : '';
			var tagNew	= ($('.ribbon-new', element).html() != null) ? '<span class="tag tag-new">New</span>' : '';
			var name 	= '<div class="name">' + tagSale + tagNew + '<a href="' + $('.name a', element).attr('href') + '">' + $('.name a', element).html() + '</a></div>';
			var addCart	= '<a class="button" onclick="' + $('.buttons .button', element).attr('onclick') + '">' + $('.buttons .button', element).html() + '</a>';
			
			var wish	= '<a href="" onclick="' + $('.buttons .button-icon:first', element).attr('onclick') + '" class="button-icon"><span class="icon icon-wish"></span><span>' + $('.buttons .button-icon:first', element).attr('title') + '</span></a>';
			var compare	= '<a href="" onclick="' + $('.buttons .button-icon:last', element).attr('onclick') + '" class="button-icon"><span class="icon icon-compare"></span><span>' + $('.buttons .button-icon:last', element).attr('title') + '</span></a>';
			
			html = '';
			
			html +=	'<div class="row">';
			html +=		image;
			html +=		name;
			html +=		rating;
			html +=		price;
			html +=		'<div class="desc">' + $('.desc', element).html() + '</div>';
			html +=		'<div class="buttons">';
			html +=			addCart;
			html +=			wish;
			html +=			compare;
			html +=		'</div>';
			html +=	'</div>';
			
			$(element).replaceWith(html);	
		});
		
		$.totalStorage('display', 'list');
	} else {
		if($('#products').hasClass('grid')) return;
		
		$('.product-filter .combo-button a:first').removeClass('active');
		$('.product-filter .combo-button a:last').addClass('active');
		
		$('#products').removeClass('rows').addClass('grid');
		$('#products > div').each(function(index, element) {
			var image 	= ($('.image', element).html() != null) ? '<a href="' + $('.image', element).attr('href') + '" class="image">' + $('.image', element).html() + '</a>' : '';
			var price 	= ($('.price', element).html() != null) ? '<div class="price">' + $('.price', element).html()  + '</div>' : '';
			var rating 	= ($('.rating', element).html() != null) ? '<div class="rating">' + $('.rating', element).html()  + '</div>' : '';
			var name 	= '<div class="name"><a href="' + $('.name a', element).attr('href') + '">' + $('.name a', element).html() + '</a></div>';
			var tagSale = ($('.tag-sale', element).html() != null) ? '<div class="ribbon-sale"></div>' : '';
			var tagNew	= ($('.tag-new', element).html() != null) ? '<div class="ribbon-new"></div>' : '';
			var addCart	= '<a class="button" onclick="' + $('.buttons .button', element).attr('onclick') + '">' + $('.buttons .button', element).html() + '</a>';
			var wish	= '<a href="" onclick="' + $('.buttons .button-icon:first', element).attr('onclick') + '" class="button-icon icon-wish" title="' + $('.buttons .button-icon:first span:last', element).html() +'"></a>';
			var compare	= '<a href="" onclick="' + $('.buttons .button-icon:last', element).attr('onclick') + '" class="button-icon icon-compare" title="' + $('.buttons .button-icon:last span:last', element).html() +'"></a>';
		
			html = '';
			
			html +=	'<div class="wrap">';
			html +=		'<div class="struct">';
			html +=			'<div class="frame">';
			html +=				tagNew;
			html +=				tagSale;
			html +=				image;
			html +=				name;
			html +=				rating;
			html +=				price;
			html += 			'<div class="desc">' + $('.desc', element).html() + '</div>';
			html +=				'<div class="buttons">';
			html +=					addCart;
			html +=					wish;
			html +=					compare;
			html +=				'</div>';
			html +=			'</div>';
			html +=		'</div>';
			html +=	'</div>';
			
			$(element).replaceWith(html);
		});
		
		$('#products .button-icon').tfToolTip();
		
		$.totalStorage('display', 'grid');
	}
}

view = $.totalStorage('display');

if(view != 'list')
	display(view);

//--></script> 
<?php echo $footer; ?>