

I'm learning a lot of things too...
Many many thanks, I hope I will be able to repay you in the future!
At the moment... I'm quite good

ciao
Max
-----------------------------------------------------------------------
My last mods: Partita IVA e CF | Pro EU VAT Number | Sales Agents | Pricelist Pro
-----------------------------------------------------------------------
Please open up your own topic but do not hijjack someone elses.antonio wrote:Antonio
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
[How to] BTW + Verzend + betaal setup.
Code: Select all
<table class="list">
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%"><?php if (isset($products[$j])) { ?>
<a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" id="image_<?php echo $products[$j]['product_id']; ?>" /></a><br />
<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
<?php } else { ?>
<span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>"><br />Qty:
<input type="input" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a></form>
<?php } ?>
<?php } ?>
<?php if ($products[$j]['rating']) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
<?php } ?>
<?php } ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
Code: Select all
<table class="list">
<?php for ($i = 0; $i < sizeof($products); $i = $i + 4) { ?>
<tr>
<?php for ($j = $i; $j < ($i + 4); $j++) { ?>
<td width="25%"><?php if (isset($products[$j])) { ?>
<a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>" title="<?php echo $products[$j]['name']; ?>" alt="<?php echo $products[$j]['name']; ?>" id="image_<?php echo $products[$j]['product_id']; ?>" /></a><br />
<a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
<span style="color: #999; font-size: 11px;"><?php echo $products[$j]['model']; ?></span><br />
<?php if ($display_price) { ?>
<?php if (!$products[$j]['special']) { ?>
<span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
<?php } else { ?>
<span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
<?php } ?>
<?php } ?>
<?php if ($products[$j]['rating']) { ?>
<img src="catalog/view/theme/default/image/stars_<?php echo $products[$j]['rating'] . '.png'; ?>" alt="<?php echo $products[$j]['stars']; ?>" />
<?php } ?>
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>"><br />Qty:
<input type="input" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a></form>
<?php } ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>
Request Reviews v1.0 released.
Request Reviews v1.0 released.
dbstr wrote:Yep, I think so.. Give it a try. It's been awhile since I've been messing with this stuff.
I know nothing about PHP and SQL, but I still try my best to understand it.
1. EDIT: catalog/view/theme/YOURTHEME/template/product/product.tplallenshea wrote: I have a question now. Our website is 'Only show prices when a customer is logged in.' How can I hide the Button and "Qty:" if they haven't log in?
Code: Select all
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="1" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
Code: Select all
<?php if ($display_price) { ?>
<div style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px;"><?php echo $text_qty; ?>
<input type="text" name="quantity" size="3" value="1" />
<a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
<?php } ?>
Code: Select all
<div class="bottom">
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>"><br />Qty:
<input type="input" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a></form>
</div>
Code: Select all
<?php if ($display_price) { ?>
<div class="bottom">
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>"><br />Qty:
<input type="input" name="quantity" size="3" value="1" />
<input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" />
<a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a></form>
</div>
<?php } ?>
I know nothing about PHP and SQL, but I still try my best to understand it.
I have been using this as a basis to create grouped products with the related products for a chosen product to display underneath it with Qty and "Add to Cart" - I have the basics working ok, although I had to changedbstr wrote:Open: catalog/controller/product/category.php
Go to line 143 and find the product array.
Find: 'model' => $result['model'],
After, insert:
'product_id' => $result['product_id'],
'href2' => $this->url->http('checkout/cart'),
Go to line 229 and find: $this->data['order'] = $order;
Insert after: $this->data['button_add_to_cart'] = $this->language->get('button_add_to_cart');
Open: product/category.tpl (in your template folder)
Add the following code, to the image tag (line 42 in standard template)Add the following code, at around line 51 (standard template):Code: Select all
id="image_<?php echo $products[$j]['product_id']; ?>"
(Small note: The quantity field is hidden, if you want it to show: change type="hidden" to type="input".Code: Select all
<form action="<?php echo $products[$j]['href2']; ?>" method="post" enctype="multipart/form-data" id="category_product_<?php echo $products[$j]['product_id']; ?>"> <input type="hidden" name="quantity" size="3" value="1" /> <input type="hidden" name="product_id" value="<?php echo $products[$j]['product_id']; ?>" /> <a class="add2cart button" onclick="$('#category_product_<?php echo $products[$j]['product_id']; ?>').submit();" id="category_product_<?php echo $products[$j]['product_id']; ?>"><span><?php echo $button_add_to_cart; ?></span></a>
Also, you might want to split this code up, but it's basic html, so it shouldn't be a problem, if you got this far)
Now to the fun part -> Open module/cart.tpl (in your template folder)
At line 59 and 60 you will find:
IN BETWEEN THOSE TWO LINES, insert this: (note: if you are insecure about this part, check the bottom)Code: Select all
}); });
Code: Select all
$('a.add2cart[class]').each(function() { var $t = $(this); $t.removeAttr('onclick') }); $("a[id^='category_product']").click(function () { var productIDValSplitter = (this.id).split("_"); var productIDVal = productIDValSplitter[2]; $.ajax({ type: 'post', url: 'index.php?route=module/cart/callback', dataType: 'html', data: $('#category_product_'+ productIDVal +' :input'), success: function (html) { $('#module_cart .middle').html(html); }, complete: function () { var image = $('#image_' + productIDVal).offset(); var cart = $('#module_cart').offset(); $('#image_' + productIDVal).before('<img src="' + $('#image_' + productIDVal).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(); }); } }); });
* If you are insecure about where to place the above code, and you haven't made any changes to the original jQuery,
you can replace the whole javascript with this:Code: Select all
<script type="text/javascript"><!-- $(document).ready(function () { $('#add_to_cart').replaceWith('<a onclick="" id="add_to_cart" class="button">' + $('#add_to_cart').html() + '</a>'); $('#add_to_cart').click(function () { $.ajax({ type: 'post', url: 'index.php?route=module/cart/callback', dataType: 'html', data: $('#product :input'), success: function (html) { $('#module_cart .middle').html(html); }, complete: function () { var image = $('#image').offset(); var cart = $('#module_cart').offset(); $('#image').before('<img src="' + $('#image').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(); }); } }); }); $('a.add2cart[class]').each(function() { var $t = $(this); $t.removeAttr('onclick') }); $("a[id^='category_product']").click(function () { var productIDValSplitter = (this.id).split("_"); var productIDVal = productIDValSplitter[2]; $.ajax({ type: 'post', url: 'index.php?route=module/cart/callback', dataType: 'html', data: $('#category_product_'+ productIDVal +' :input'), success: function (html) { $('#module_cart .middle').html(html); }, complete: function () { var image = $('#image_' + productIDVal).offset(); var cart = $('#module_cart').offset(); $('#image_' + productIDVal).before('<img src="' + $('#image_' + productIDVal).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>
“Reeling and Writhing, of course, to begin with, and then the different branches of arithmetic -- Ambition, Distraction, Uglification, and Derision." - The Mock Turtle
Users browsing this forum: No registered users and 3 guests